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 show is how you zoom in on exactly one commit once git log has helped you find it - it prints the full commit message plus the complete diff it introduced, so you can see both what changed and why (from the message) in one place.
git blame - who last touched each line
Scenario: A weird line of config is breaking prod and nobody remembers writing it. Before yougit blamea person, yougit blamethe file - it annotates every single line with the commit, author, and date that most recently changed it. Then you read that commit's message (withgit show) to learn the why behind the change.
$ 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 (much faster on huge files) |
git show <commit> | View a commit's full message + diff |
Tip: The two commands are meant to be used together:git blamepoints you to a commit hash;git show <hash>then reveals the full context and reasoning behind that specific line. Despite the name, blame is a tool for understanding history, not for pointing fingers at a teammate - in a healthy team, "let me blame this line" just means "let me find out why this is here".