Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Diff

Direct 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.

When to use this

Use it when configuring, checking or troubleshooting Diff in Git.

First 30 seconds

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.

Operational verification

old ↔ new → diff

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Git version-control automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformGit version-control automation · Diff owns Git comparison semantics. Domain-specific config/code validation owns semantic interpretation and runtime effect.
Scope / prerequisiteUse it when configuring, checking or troubleshooting Diff in Git.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

4 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 diff of 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 references

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.

observation · 1
Key points
  • 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.
Key checks
  • git diff — unstaged changes
  • git diff --staged — staged
  • git 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docGit version-control automation current

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%
Terminology layer

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.

Aliases that resolve here
git diffcompare commitsstaged diffworking tree diff
Embedded reference data

Quick lookup tables

Diff Git boundary map

Fast local-state, history/ref, remote and downstream proof boundaries for Diff.

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
Depth when you need it

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.

Confirmation

Confirm action

Continue?