Skip to content

Instantly share code, notes, and snippets.

@aeden
Created October 22, 2009 01:52
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 aeden/215654 to your computer and use it in GitHub Desktop.
Save aeden/215654 to your computer and use it in GitHub Desktop.
Checkout:
git clone url
Checkout throwing away local changes:
git checkout -f
Checkout a single file to get it back to HEAD:
git checkout filename
Checkout a single file to a specific REV:
git checkout REV filename
To unstage a single file:
git reset HEAD filepath
To modify the last commit message
git commit --amend
To create a local branch:
git branch branch_name
To create a local branch from a tag:
git branch x-y-z x.y.z
To push a local branch to the remote:
git push origin branch_name
To delete a remote branch:
git push origin :branch_name
To delete a local branch:
git branch -d branch_name
To checkout and track a remote branch:
git checkout --track -b local_branch origin/remote_branch
Show remote branches:
git remote show origin
Add all deleted files:
git add -u
Log with hash + name + subject (useful with | grep)
git log --format=format:"%H %an %s"
Generate a giant patch from the current branch against master
git format-patch master --stdout
Apply a formatted patch
git am —3way < /tmp/name.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment