Guide
Review a Git diff
A Git diff compares two states and shows the changes between them. Before reviewing its lines, identify the two states being compared: working files against the index, the index against a commit, or one commit against another.
At a glance
- Unstaged comparison
- git diff
- Staged comparison
- git diff --cached
Overview
A Git diff compares two states and shows the changes between them. Before reviewing its lines, identify the two states being compared: working files against the index, the index against a commit, or one commit against another. The comparison determines what you are actually approving.
1. Choose the comparison
Use the diff command appropriate to the review target. Check status alongside it so that untracked files or changes outside the selected comparison do not disappear from your understanding of the work.
2. Read context and behavior
Inspect surrounding code and affected callers rather than judging isolated added lines. Look for changes to inputs, error paths, permissions, and persisted data that may have consequences beyond the edited function.
3. Connect evidence to the change
Run or inspect the checks relevant to the changed behavior. Record specific unresolved questions and distinguish a visual code review from a workflow that has actually been exercised.
Sources and review
MOOR's explanatory text is supported by the following source links.
- git diff reference — Git
- Recording and inspecting changes — Pro Git