Git Code Review
In this page:
Comparing Changes with Git Diff
git diff <base>...<branch> shows exactly what a branch changes relative to where it forked from, which is the starting point of most code reviews — it's the actual content a reviewer needs to evaluate, as opposed to the commit messages or file list alone.
Example: Comparing Changes with Git Diff
git diff main...feature-login
Viewing Commit History of a Branch
git log <base>..<branch> lists just the commits unique to that branch, letting a reviewer follow the author's train of thought — whether they built the feature incrementally with focused commits or dumped everything into one, which itself is often worth commenting on.
Example: Viewing Commit History of a Branch
git log main..feature-login
Checking Out a Specific Commit
git checkout <commit> (landing you in a detached-HEAD state) lets a reviewer actually run the code as it existed at any point in a branch's history, useful for verifying a specific claim in the PR or reproducing a bug the change is supposed to fix.
Example: Checking Out a Specific Commit
git checkout a1b2c3d
Finding Authors with Git Blame
When a review needs to know who to ask about a confusing piece of existing code (not the new change itself), git blame on that file points straight to the commit and author responsible, saving a round of "does anyone know why this is here?" in the review thread.
Example: Finding Authors with Git Blame
git blame file.txt
Using Git Show to Inspect Commits
git show <commit> displays a single commit's metadata and diff together in one view, which is often faster for reviewing one focused commit than scrolling through a full multi-commit branch diff.
Example: Using Git Show to Inspect Commits
git show a1b2c3d
Chapter Quiz — Complete all 6 topics to unlock
0/6 topics done
Complete these topics first: