Diff
Cheat sheet · https://pcornel.dk/topic.php?topic=5476
Answer
Git diff compares selected states such as working tree, index, commits or refs; its meaning depends entirely on which two boundaries are being compared.
Remember
- 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.
First checks
git diff— unstaged changesgit diff --staged— stagedgit diff main...feature— branch changes
Verify in this order
old ↔ new → diff
Where it usually breaks
A diff proves differences between the selected Git states and paths; it does not prove omitted/untracked state is absent or that behavior changed as expected.
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Diff Git boundary map
| 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 |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5476