Git & Version Control · Cheatsheet
Git History and Diffs Cheatsheet
Inspect Git history, compare revisions, follow file changes, and read reflogs. Check the difference between log ranges and snapshot comparisons.
38 commands 7 sections
No entry matches that filter.
-
<commit>, <branch>, <file>Replace each placeholder with a real revision, branch, or path -
Read-only referenceThese inspection commands do not change tracked files or commits -
A..B versus A...BLog ranges select commits; diff ranges compare file snapshots -
Saved commits onlyHistory cannot recover edits that Git never recorded
-
git status --short --branchShow file state and branch tracking -
git diff -- <file>Compare an unstaged file with the index -
git diff --cached -- <file>Compare staged content with HEAD -
git diff HEAD -- <file>Compare the working file with the last commit -
git diff --statSummarize unstaged changes by file -
git diff --checkCheck unstaged changes for whitespace errors
-
git log -10 --onelineList the ten most recent commits -
git log --all --graph --decorate --onelineShow reachable branch history as a graph -
git log --first-parent --onelineFollow the first parent through merge commits -
git log --since="2 weeks ago" --onelineFilter history by a relative date -
git log --author="Alex" --onelineMatch the author with a regular expression -
git log --grep="timeout" --onelineFind commit messages that match the pattern
-
git diff main feature --Compare the two branch tips -
git diff main...feature --Compare the merge base with the feature tip -
git log main..feature --onelineList feature commits absent from main -
git log --left-right main...feature --onelineShow commits unique to either branch -
git diff --name-status HEAD~1 HEAD --List changed paths and status in the last commit -
git show --stat <commit>Show a commit summary and file statistics
-
git log --follow --oneline -- <file>Follow one file across detected renames -
git log -p -- <file>Show patches from the file history -
git log -S"timeout" -- <file>Find commits that change the count of this exact text -
git log -G"timeout.*=" -- <file>Find added or removed lines that match the regex -
git blame -L 10,20 -- <file>Show the last recorded change for lines 10 through 20 -
git show HEAD:<file>Read a repository-relative path from the last commit
-
git reflog show --date=iso HEADList local HEAD movements while their reflog entries remain -
git show --format=fuller --no-patch <commit>Show author and committer metadata -
git branch --contains <commit>List local branches that contain the commit -
git tag --contains <commit>List tags whose history contains the commit