Reading Your Repository

status, diff, and log - the three commands that only look, never change

Most git fear is acting blind: running a command without knowing what state the repository is in. Three instruments make blind unnecessary, and none of them changes your files, staged copies, commits, or branches: git status says WHERE things differ, git diff shows the exact lines, git log walks the history. Read first, act second - the whole chapter is that habit.

$ git status --short   # right after the add -p session
MM report.md
one real invocation, one row - left column staging, right column desk

git status is a set of comparisons, not a mood. Each FILE line names which two places disagree about which file: staged vs last commit (to be committed), working directory vs staged (not staged), and paths the staging area does not hold (untracked). The short form says the same in two letters - left column staging, right column working directory. MM therefore reads: staged once, edited again since.

$ git diff HEAD
... (diff + hunk headers trimmed)
 menu
 - soup: 4
 - salad: 5
+- bread: 3
+- olives: 4
both edits in one view

git diff in these everyday forms compares TWO places; the flag picks them. Plain diff: working directory vs staging. --staged: staging vs last commit. HEAD: working directory vs last commit - the whole distance. The fixture's one moment proves it: a staged bread line, an unstaged olives line, and each view selects its own truth.

The output convention is git's own everywhere: + added, - removed. And silence is an answer: no output means those two places agree - it never means the whole repository is clean. Only status says that.

dk-lead
dk-s1
dk-m1
dk-s2
dk-m2
dk-s3
dk-m3
dk-s4
dk-m4
two walks, one repository - each thread sees only its own past
two walks, one repository - each thread sees only its own past

git log is a walk along parent pointers, backward from where you stand - which is why two branches print two different histories from the same repository. In the fixture, main's walk never meets the garlic-bread commit, and the branch's walk never meets main's newest - neither is missing; neither is an ancestor of the other. --all starts from every branch and tag, and --graph draws the fork you already know from the mental model.

Small habits that pay forever: git log --oneline for one line per commit (if log opens a pager, q quits it); short ids abbreviate the full id (40 or 64 hex characters, by repository format); any unique prefix of four or more characters works; git status before every stage, seal, or switch. The instruments are free - use them constantly.

beat-miscon
tearline