Last active
August 29, 2015 14:00
-
-
Save LutherBaker/11016953 to your computer and use it in GitHub Desktop.
Git Cheatsheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 <[email protected]>" | |
$ 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