- How to rebase a forked repository
- How to add a default editor to git
- How to amend to some old commit?
- How to amend delete merged branches?
My Git Cheat List
How to rebase a forked repository
On the cloned repository
$ git checkout master $ git remote add upstream email@example.com.../other/repo.git $ git fetch upstream $ git rebase upstream/master $ git checkout my-branch $ git rebase master
How to add a default editor to git
$ git config --global core.editor vim
How to amend to some old commit?
$ git log
Get the hash of the commit you wish to edit
$ git rebase -i 123456
It will open your editor with the commit options written as pick
Change it to edit
Your branch name is now changed to the commit’s hash. Edit your files then:
$ git add yourfile $ git commit --amend
Once you have finished all changes:
$ git rebase --continue
Everything is back to normal. Since you made a rebase, you need a “forced” push:
$ git push -f
How to amend delete merged branches?
This delete all merged branch. Do NOT use
$ for branch in `git branch | grep -v master`; do git branch -d $branch; done