Skip to content

Instantly share code, notes, and snippets.

@LutherBaker
Last active August 29, 2015 14:00
Show Gist options
  • Save LutherBaker/11016953 to your computer and use it in GitHub Desktop.
Save LutherBaker/11016953 to your computer and use it in GitHub Desktop.
Git Cheatsheet
# Tracking a remote branch
git checkout -t origin/branchname
git checkout --track -b star origin/star
# Ignore changes to tracked files (.gitignore for untracked files)
git update-index --assume-unchanged <filenames> # begin ignoring changes to <filenames>
git update-index --no-assume-unchanged <filenames> # start tracking changes again to <filenames>
# Revert the last commit but keep my local file changes
git reset --mixed 'HEAD^'
# Initial push
git push --set-upstream origin <branch>
# Quick reminders
git reset --hard <SHA> # clear index, clear file changes, point to SHA
git reset --mixed <SHA> # clear index, keep file changes, point to SHA
git reset --soft <SHA> # keep index, keep file changes, point to SHA
# Clearing the password cache
$ git config credential.helper 'cache --timeout=1'
# Stopping the password cache
$ git credential-cache exit
# Amend your last commit
$ git commit --amend
$ git commit --amend --author "Author's Name <name@host.com>"
$ git commit --amend --reset-author
# Rebase
$ git rebase -i HEAD~4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment