git show
The Inspection
git show looks like a single command, but it is really just two operations fused together: it fetches the commit's metadata (like git log -1) and then computes the diff against its parent (like git diff parent..commit). Understanding this makes its output obvious.
Two Steps, One Command
Click the button below to watch how git show fans out into two parallel operations before merging the results.
git show Output
Step 1: The Commit Object
Git opens the commit object and reads its fields directly: author, committer, the timestamp, and the commit message. This is identical to what git log -1 <hash> prints.
Crucially, it also reads the parent field — the hash of the previous commit. This is the key it needs for Step 2.
Step 2: The Diff
With the parent hash in hand, Git opens both Tree Objects — the parent's tree and the current commit's tree — and computes the line-by-line diff. This is exactly what git diff parent commit would produce.
The two results are concatenated into a single output. That's the entire magic of git show.
The Equivalent Commands
You can always decompose git show <hash> into two explicit commands. This is useful when you only want one half of the output.