Who & When - show & blame
git show - inspect one commit
$ git show a1b2c3d # message + full diff of that commit
$ git show HEAD:app.py # a file's contents AS OF that commit
git blame - who last touched each line
Scenario: A weird line of config is breaking prod. Before you git blame a person, you git blame the file to find which commit (and author, and date) introduced that line - then read that commit's message for the why.
$ git blame config.txt
a1b2c3d (Alice 2024-03-01 14:22) port=8080
9f8e7d6 (Bob 2024-03-05 09:10) timeout=30
| Command | Does |
|---|
git blame <file> | Annotate every line with its last commit/author |
git blame -L 10,20 <file> | Only lines 10-20 |
git show <commit> | View a commit's message + diff |
Tip: git blame points you to a commit hash; then git show <hash> reveals the full context and reasoning. Blame is for understanding, not for pointing fingers.