Pcornel
Automation · Git

Diff

Cheat sheet · https://pcornel.dk/topic.php?topic=5476

Back to the Topic

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 changes
  • git diff --staged — staged
  • git 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

BoundaryHealthy evidenceSuspicious evidence
Local stateRepository, HEAD, worktree/index and commit IDs are explicitWrong repo/ref, hidden staged/untracked state or mutable-name ambiguity
History / refsAncestry and branch/tag movement match intentUnexpected rewrite, stale tracking ref or unclear merge base
Remote syncURL/refspec, auth and remote read-back match expected commitsLocal assumptions, rejection, stale fetch or unsafe force update
Downstream proofBuild/reconciliation/target is verified independentlyPush/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

Confirmation

Confirm action

Continue?