Show Menu

Cheat Sheet for the Git Distributed Version Control System. Based on and

Create Git Repository

From existing directory
cd projec­t_dir
git init
git add .
From other repository
git clone existi­ng_dir new_dir
git clone git://­git­­m/u­ser­/re­po.git
git clone https:­//g­ith­ub.c­om­/us­er/­rep­o.git

Git - Local Changes

Changed in working directory
git status
Tracked file changes
git diff
Add changed files
git add file1 file2 file3
Remove file
git rm file
git rm dir/ -r
(recursive under directory)
See files ready for commit
git diff --cached
Commit changes
git commit
git commit -m "My messag­e"
git commit -a -m "My Messag­e"
(tracked files only, auto add)
Change last commit
git commit --amend
Revert changes to file
git checkout -- file
Revert changes (new commit)
git revert HEAD
Return to last committed state
git reset --hard HEAD

Git - History

Show all commits
git log
Short Format
git log --pret­ty=­short
git log -p
Show file commits
git log file
Show directory commits
git log dir/
git log --stat
Who changed file
git blame file

Git - Merge/­Rebase

Merge branch into current
git merge branch
Rebase into branch
git rebase branch
git rebase master branch
Abort rebase
git rebase --abort
Merge tool to solve conflicts
git mergetool
Conflicts against base file
git diff --base file
Diff other users changes
git diff --theirs file
Diff your changes
git diff --ours file
After resolving conflicts
git rebase --continue

Git - Remote Update / Publish

List remotes
git remote -v
Show inform­ation
git remote show remote
Add remote
git remote add path/url
Fetch changes
git fetch remote
Fetch + merge
git pull remote branch
Publish local to remote
git push remote branch
Delete remote branch
git push remote :branch
Publish tags
git push --tags

Git - Branch­ing­/Ta­gging

List branches
git branch
Switch to branch
git checkout branch
Create new branch
git branch new
Create branch from existing
git branch new existing
Delete branch
git branch -d branch
Tag current commit
git tag tag-name


Sam, that's brilliant! I'm still using SVN, but dabbling in Git, and this is just the thing to help me make the jump. Great cheat sheet!

Yes, the content is exactly what I am looking for too. It would be even better for these tired old eyes with <font size=+2pt> lol.

I'm sure that increasing the font size won't cause any problems width-wise; plenty of space in all three columns, even with Letter-sized paper. And there's space aplenty at the bottom of an A4 page so there's be even more on Letter-sized paper.

Great cheat sheet all the same!

Best GIT sheet here. Could you please add "Rename branch" (or "Move branch") to one of the blocks (probably last); `git branch -m *new* *existing*`

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Git Flow Cheat Sheet
          Git Cheat Sheet by SamCollett [RUS] WIP Cheat Sheet