# remotes - pushing, pulling, and tracking git fetch # gets remote objects and refs. Needed if new branches were added on the remote. git remote -v # Lists all remotes (verbose) git pull origin master # Pulls commits from the 'origin' remote's master branch and stores them in the local repo git push -u origin master # sets ups tracking so that you can 'git push' without extra args git show :/^Merge # show the last commit whose message matches a regex # branches - creating, checking out, and merging git branch # list branches git branch -a # list branches including remotes git branch MYBRANCH # Creates a new branch called "MYBRANCH" git checkout MYBRANCH # Makes MYBRANCH the active branch git checkout -b MYBRANCH # Shortcut to create and checkout a new branch git branch -d # delete a local branch git checkout --track origin/ # create a new local branch with the same name as the remote and set "upstream" configuration git merge # merge the commits from the given branch into the current branch # tagging git tag # list available tags git tag -l v1.4.2.* # search for specific tags git tag -a v1.4 -m 'version 1.4' # create an annotated tag git tag -a v1.2 9fceb02 # tag a specific commit (if you forgot) git show v1.4 # show the tag data of a specific tag git tag v1.4 # create a lightweight tag git push --tag # you have to explicitly push tags to remotes git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d' # show tags with creation dates # diff git diff --word-diff git diff --staged # show the changes that have been staged # reset git reset # unstage git checkout -- # throw away local modifications and reset to last committed version of given file git reset --hard HEAD # throw away local modifications and reset to latest of current branch git reset --hard 0c6de32 # throw away local modifications and reset to specific commit git clean -f # remove untracked files git revert HEAD # Make a commit that undoes the last commit. Used to reset a commit that # has already been pushed to a remote. # create a new repo from a directory in an old repo, preserving history git clone cd git remote rm origin git filter-branch --subdirectory-filter -- --all cd curl -u '' https://api.github.com/user/repos -d '{"name":""}' git remote add origin git push origin master