Repository Archaeology
five questions history answers - who, when, which lines, which commits, what changed
Every archaeology session starts as a question, not a command. Someone asks who set the oven to 110, or when did this line change, or what shipped between those two releases. This chapter walks one real repository - a pizzeria's config files - asking each question with the query built for it. Every output below was executed against that repository.
$ git blame bake.txt -L 3,7
33eead92 (Maria 2026-02-01 10:14:00 +0000 3) bake_minutes=20
^499f50c (Maria 2026-02-01 10:01:00 +0000 4) preheat=full
... (lines 5-6 elided)
4ebb89a9 (Maria 2026-02-01 10:15:00 +0000 7) oven_temp=110WHO? git blame stamps every line's margin with the commit that last changed it - id, author, date. The ^ prefix marks a BOUNDARY of blame's walk - here that boundary is the root commit, so those lines are unchanged since it. Read the margin, then open that commit's message: that is the whole workflow.
$ git log -S 'oven_temp' --oneline
499f50c open the pizzeria recordsWHEN DID IT CHANGE? git log -S 'oven_temp' finds the commits where that string's COUNT changed - born, deleted, or duplicated. An edit that keeps the count does not match; that is the pickaxe's precision. Here oven_temp traces straight to the opening commit.
$ git log --oneline -- carte.txt
09b841c rename menu to carte
$ git log --oneline --follow -- carte.txt
09b841c rename menu to carte
3ef4ef0 special becomes quattro formaggi
36126d3 special becomes diavola
499f50c open the pizzeria recordsWHICH LINES? git log -L 3,7:bake.txt traces the evolving life of a line range anchored in the starting revision - the commits that shaped those lines, usually each with its patch (merge commits appear without one).
WHICH COMMITS TOUCHED THE FILE? git log -- <path> narrows the walk to one file's story - the commits that explain how it got here (git simplifies ancestry around merges). Renames need --follow: without it the walk stops where the name began; with it - on a straightforward history like this one - the file's earlier life appears: carte.txt reaches back through its days as menu.txt.
$ git log --oneline tweak...tweak-refiled
b3742b6 tiramisu price rises (re-filed with cleaner note)
c5e89dc tiramisu price rises
$ git diff tweak tweak-refiled -- menu.txt # prints NOTHINGWHAT CHANGED BETWEEN TWO MOMENTS? Two grammars, two questions. git log A..B asks the graph: commits B has that A does not; git log A...B widens it to either-side-not-both. git diff A B asks no graph question - it lifts two snapshots and prints their difference. The pizzeria's proof: two branches made the SAME edit, so the symmetric range shows two commits - and the diff prints nothing.
The habit that makes archaeology fast: name the question first, then reach for its query. Who = blame. When = -S. Which lines = -L. Which commits = -- <path>. What changed = diff A B. Log queries land on commits - moments on the line you already read; diff hands you the difference itself.