Skip to content

Instantly share code, notes, and snippets.

@philly-mac
Last active September 26, 2015 21:37
Show Gist options
  • Save philly-mac/1162650 to your computer and use it in GitHub Desktop.
Save philly-mac/1162650 to your computer and use it in GitHub Desktop.
Because I always forget the syntax of some git commands
# <remote> is usually origin
# Check out remote branch
git checkout -b <local-branch-name> <remote>/<remote-branch-name>
# Delete local branch
git branch -D <local-branch-name>
# Delete remote branch
git push <remote> :<remote-branch>
# Create new local branch
git branch <local-branch-name>
# Push to a new remote branch
git push <remote> <remote-branch-name>
# Make local branch track remote branch
git branch --set-upstream <local-branch-name> <remote>/<remote-branch-name>
# Check out file from another branch
git checkout <branch-name> -- <file-path>
# Push a new remote branch and track it
git push -u <remote> <branch-name>
# Delete git tag
git tag -d <tag-name>
git push <remote> :refs/tags/<tag-name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment