Git Cheat Sheet
by Sam Collett (SamCollett) via cheatography.com/196/cs/104/
Create Git Repository Git - History Git - Remote Update / Publish
From existing directory Show all commits List remotes
cd project_dir git log git remote -v
git init Short Format Show information
git add . git log --pretty=short git remote show remote
From other repository Patches Add remote
git clone existing_dir new_dir git log -p git remote add path/url
git clone git://github.com/user/repo.git Show file commits Fetch changes
git clone https://github.com
/user/repo.git git log file git fetch remote
Show directory commits Fetch + merge
Git - Local Changes
git log dir/ git pull remote branch
Changed in working directory
Stats Publish local to remote
git status
git log --stat git push remote branch
Tracked file changes
Who changed file Delete remote branch
git diff
git blame file git push remote :branch
Add changed files
Publish tags
git add file1 file2 file3 Git - Merge/Rebase
git push --tags
Remove file Merge branch into current
git rm file git merge branch Git - Branching/Tagging
git rm dir/ -r Rebase into branch List branches
(recursive under directory) git rebase branch git branch
See files ready for commit git rebase master branch Switch to branch
git diff --cached Abort rebase git checkout branch
Commit changes git rebase --abort Create new branch
git commit Merge tool to solve conflicts git branch new
git commit -m "My message" git mergetool Create branch from existing
git commit -a -m "My Message" Conflicts against base file git branch new existing
(tracked files only, auto add) git diff --base file Delete branch
Change last commit
Diff other users changes git branch -d branch
git commit --amend git diff --theirs file Tag current commit
Revert changes to file
Diff your changes git tag tag-name
git checkout -- file
git diff --ours file
Revert changes (new commit)
After resolving conflicts
git revert HEAD
git rebase --continue
Return to last committed state
git reset --hard HEAD
By Sam Collett (SamCollett) Published 23rd November, 2011. Sponsored by CrosswordCheats.com
cheatography.com/samcollett/ Last updated 1st June, 2014. Learn to solve cryptic crosswords!
www.texotela.co.uk Page 1 of 1. http://crosswordcheats.com