Skip to the content.

GIT CHEATSHEET (中文速查表)

branch

git checkout -b dev     # Create & switch to a new branch 'dev'
git branch dev          # Create a new branch 'dev'
git checkout dev        # Switch to branch 'dev'

log

git log                        # Show the whole commit history
git log -n 2                   # Show only 2 commits
git log -2                     # Same as 'git log -n 2'
git log -p                     # Show the patch for each commit as well as their full diff
git log commit_id              # Show commit history before commit_id, including commit_id
git log commit_id1 commit_id2  # Show commit history between commit_id1 and commit_id2,
                               # including commit_id1 and commit_id2
git log commit_id -p -1        # Show the patch for commit_id