Skip to content

Instantly share code, notes, and snippets.

@akofman
Last active January 13, 2016 23:50
Show Gist options
  • Save akofman/10940915 to your computer and use it in GitHub Desktop.
Save akofman/10940915 to your computer and use it in GitHub Desktop.

1. Having two branches, branch1 and branch2, to know which commits are in branch1 but not in branch2 :
git checkout branch1
git cherry -v branch2

the output will be something like :

+ 2dcf5fec8c4f7ff474512b85378d8a0347f5850d commit message
+ 90f55270f9796038d7bc35938890469f34fe0091 commit message

2. Commit only part of a file :
git commit -p file

3. Update the tracking info of an existing branch :
git branch --set-upstream-to origin/master existingbranch

For instance :

$ git checkout -b localbranch
$ git branch -vv 
...
* localbranch   d5a2069 docs(tutorial): fix typo in module name
...
$ git branch --set-upstream-to origin/master localbranch
$ git branch -vv
...
* localbranch   d5a2069 [origin/master] docs(tutorial): fix typo in module name
...
4. Do not edit an amended commit :
$ git commit --amend --no-edit
5. Restore an uncommited deleted file :
$ git checkout HEAD <filename>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment