Clone an existing repository
git clone _[repository]_
Create a new local respository
git init
Show changed files in your working directory
git status
Show changes to tracked files
git diff
Add all changes to the next commit
git add .
Add changes in [file] to the next commit
git add -p _[file]_
Commit all local changes in tracked files
git commit -a
Commit previously staged changes
git commit
Change the last commit
git commit --amend
Show all commits, starting with most recent
git log
Show changes over time to [file]
git log -p _[file]_
Show changes for [file] with time and author
git blame _[file]_
List local branches
git branch
List both local and remote branches
git branch -a
List remote branches
git branch -r
Switch HEAD branch
git checkout _[branch]_
Create new branch based on current HEAD
git branch _[new branch]_
Create new tracking branch based on a remote branch
git branch --track _[new branch]_ _[remote branch]_
Delete local branch
git branch -d _[branch]_
Mark the current commit with a tag
git tag _[tag name]_
Refresh list of remotes
git remote update
List all currently configured remotes
git remote -v
Display information about [remote]
git remote show _[remote]_
Add a new remote, named [remote]
git remote add _[remote]_ _[url]_
Download all changes from [remote], don't integrate into HEAD
git fetch _[remote]_
Download changes and merge to HEAD
git pull _[remote]_ _[branch]_
Publish local changes
git push _[remote]_ _[branch]_
Delete a branch on the remote
git push _[remote]_ :_[branch]_
Publish tags
git push --tags
Merge [branch] into your current HEAD
git merge _[branch]_
Rebase your HEAD onto [branch]
git rebase _[branch]_
Abort a rebase
git rebase --abort
Continue a rebase after resolving conflicts
git rebase --continue
Use configured merge tool to resolve conflicts
git mergetool
Temporarily store all modified tracked files
git stash
Restore most recently stashed files
git stash pop
List all stashed changes
git stash list
Discard most recently stashed changeset
git stash drop
Discard all local changes in your working directory
git reset --hard HEAD
Discard local changes in [file]
git checkout HEAD _[file]_
Revert a commit
git revert _[commit]_
Reset HEAD to a previous commit and discard all changes since
git reset --hard _[commit]_
Reset HEAD to a previous commit and preserve all changes as unstaged changes
git reset _[commit]_
Reset HEAD to a previous commit and preserve uncommitted local changes
git reset --keep _[commit]_