Use it when configuring, checking or troubleshooting Diff in Git.
Diff
Git diff compares selected states such as working tree, index, commits or refs; its meaning depends entirely on which two boundaries are being compared.
1. Diff shows changes.
2. Review before commit and in PRs.
3. --word-diff for prose.
4. Ignore whitespace when useful (-w).
5. Check generated files.
old ↔ new → diff
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
left state identity → right state identity → tree/path selection → textual/binary diff → review/classification → project validation
Healthy evidence: comparison endpoints and path scope are explicit, untracked/ignored context is known and semantic validation follows where required.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: comparing wrong endpoints, overlooking staged/untracked files, mutable branch-name comparisons or treating no textual diff as evidence of no drift.
Step 3 Common mistakes Narrow the fault
- Reviewing without
git diffof the exact change.
Step 4 Where it fails Narrow the fault
Where Diff usually goes wrong: comparison base/head identity, staged/unstaged scope, rename/binary handling and interpretation limits.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Empty diff ≠ no relevant change; untracked or ignored files and generated external state may be outside the comparison.
- Working-tree diff ≠ staged diff; default comparisons can omit index changes depending on invocation.
- Textual difference ≠ behavioral difference; whitespace or generated metadata may be irrelevant while small changes can be critical.
- Diff between branch names ≠ immutable comparison; moving refs can change results over time.
git diff— unstaged changesgit diff --staged— stagedgit diff main...feature— branch changes
ReferenceWhat it is1 section · depth on demand
Core model
Always identify left/right comparison endpoints and whether untracked/ignored content is outside the selected diff. Use diff as evidence of textual/tree differences, not as evidence of semantic behavior.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
A diff shows differences between the selected Git states and paths, but it does not show omitted/untracked state is absent or that behavior changed as expected.
In depth
git diff shows line-by-line differences between versions: working tree vs staging, staging vs last commit, or any two commits or branches. In automation repositories, diffs are how reviewers see exactly what configuration will change.
git diff # unstaged changes
git diff --staged # what will be committed
git diff main...feature/x # changes on a branch since it diverged
git diff --stat v1.3.0 v1.4.0
git diff --word-diff
Generate rendered configurations in CI and diff them against the previous version — reviewing the actual device config change is far clearer than reviewing template code alone.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Git > Diff. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://git-scm.com/docs · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Diff Git boundary map
Fast local-state, history/ref, remote and downstream proof boundaries for Diff.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Local state | Repository, HEAD, worktree/index and commit IDs are explicit | Wrong repo/ref, hidden staged/untracked state or mutable-name ambiguity |
| History / refs | Ancestry and branch/tag movement match intent | Unexpected rewrite, stale tracking ref or unclear merge base |
| Remote sync | URL/refspec, auth and remote read-back match expected commits | Local assumptions, rejection, stale fetch or unsafe force update |
| Downstream proof | Build/reconciliation/target is verified independently | Push/tag/merge success treated as deployment success |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For Diff, rely on structured fields and stable IDs (comparison base/head identity, staged/unstaged scope, rename/binary handling and interpretation limits) rather than text formatted for display.