Skip to content

Instantly share code, notes, and snippets.

@euler0
Last active October 14, 2015 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save euler0/4285394 to your computer and use it in GitHub Desktop.
Save euler0/4285394 to your computer and use it in GitHub Desktop.
Git Cheat Sheet
# Delete a remote branch (or a tag)
$ git push origin --delete branch
# Or a syntactic sugar
$ git push origin :branch
# Delete a remote-tracking branch
$ git branch -r -d origin/branch
# Squash the last 4 commits
$ git rebase -i HEAD~4
# Undo a merge
$ git reset --hard HEAD^
# git reset --hard HEAD~4
# Track a remote branch
$ git branch --set-upstream foo origin/foo
# As of Git 1.8.0
$ git branch -u origin/foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment