Skip to content
rajin

11Understanding status and diff

core25–30 minHandbook pp. 27–28 Not started

Warm-up · from “What add and commit actually do”

When is a blob normally written?

No notes: write what you remember, then check. Recalling before reading is what makes it stick.

The problem

Your pull request includes a surprise line. Learn to inspect exactly what is staged, what is only on disk and what changed between commits.

After this lesson you can

  • Interpret short status.

  • Choose the correct diff comparison.

  • Explain why untracked files do not appear in ordinary diff.

Key terms

Full glossary

Say what each term means, then open it to check.

  • Index · from lesson 9

    Prepared path-to-object entries, plus metadata and conflict stages.

  • Commit · from lesson 7

    Object identifying a root tree, parent(s), metadata and message.

  • Tree · from lesson 6

    Directory snapshot mapping names, modes and object IDs.

  • HEAD · preview, covered in lesson 14

    Current symbolic branch reference or detached commit identity.

Visual mental model

  1. HEAD
  2. Indexdiff --staged
  3. Working treediff
HEAD vs Index = diff --staged · Index vs working tree = diff

Build the mental model

Plain git diff compares working files with the Index, showing unstaged tracked changes. git diff --staged compares the Index to HEAD (or an empty tree before the first commit). git diff HEAD compares tracked working-tree state with the current commit. Untracked files normally do not appear in these diffs; use status to discover them.

SimulationWhich comparison shows what?

A simplified model for building intuition. It does not read your sandbox; use the terminal for real behaviour.

Under the hood

Short status has two columns: the first describes Index changes relative to HEAD, and the second describes working changes relative to the Index, except special conflict and untracked cases. MM means modified in both comparisons. In a unified diff, minus lines were removed, plus lines were added, and context helps locate the change. Inspect a diff before staging and before committing.

Common mistake · important nuance

The two dots and three dots of revision ranges have command-specific meanings; see lesson 15.

Move between parts freely. Completion counts only what you verify and answer.