echo "# error-handling" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/bijay-shrestha/error-handling.git
git push -u origin master
Follow this link
echo '.idea' >> .gitignore
git rm -r --cached .idea
git add .gitignore
git commit -m '<write some message stating the file is removed>'
git push
$ git reset --hard <commidId> && git clean -f
$ git push --delete <remote_name> <branch_name>
$ git branch -d <branch_name>
Note that in most cases the remote name is origin
.
Use the git remote rm
command to remove a remote URL
from your repository.
The git remote rm
command takes one argument:
A remote name, for example, destination
$ git remote -v
# View current remotes
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
> destination https://github.com/FORKER/REPOSITORY.git (fetch)
> destination https://github.com/FORKER/REPOSITORY.git (push)
$ git remote rm destination
# Remove remote
$ git remote -v
# Verify it's gone
> origin https://github.com/OWNER/REPOSITORY.git (fetch)
> origin https://github.com/OWNER/REPOSITORY.git (push)
git pull origin master --allow-unrelated-histories
git branch -m new-name
git update-index --assume-unchanged <file>
#add 'node_modules' to .gitignore file
git rm -r --cached node_modules
git commit -m 'Remove the now ignored directory node_modules'
git push origin master
If you are on the branch you want to rename:
git branch -m new-name
If you are on a different branch:
git branch -m old-name new-name
git push origin :old-name new-name
Switch to the branch and then:
git push origin -u new-name
To amend the commit messages of the last two commits in Git, follow these steps:
##Step 1: Use Interactive Rebase Run the following command to start an interactive rebase for the last two commits:
git rebase -i HEAD~2
##Step 2: Edit the Commit Messages In the interactive rebase interface:
You'll see something like this:
pick def456 Second commit message```
Change the word pick to reword for the commits whose messages you want to edit:
```reword abc123 First commit message
reword def456 Second commit message```
Save and close the editor (usually by pressing :wq in vim).
##Step 3: Update the Commit Messages
Git will now let you edit the messages one by one:
For the first commit, it will open the commit message editor. Modify the message as needed, save, and close.
Then it will do the same for the second commit.
##Step 4: Complete the Rebase
After editing both commit messages, Git will complete the rebase. If there are no conflicts, you're done!
##Step 5: Push Changes (If Necessary)
If you already pushed these commits to a remote branch, you'll need to force push the updated history:
`git push --force`