Part III: Chapter 3.7

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.

Step 1 — Fetch commit object
Waiting...
Step 2 — Diff parent → commit
Waiting...

git show Output

commit c4d5e89...
Author: Badu <badu@git.com>
Date: Tue Apr 29 14:00:00 2026 -0400
 
Fix layout bug
 
diff --git a/style.css b/style.css
--- a/style.css
+++ b/style.css
body {
- color: white;
+ color: red;
+ padding: 10px;
}

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.

Terminal
$# See only the metadata (no diff):
$git log -1 c4d5e
commit c4d5e89...
Author: Badu <badu@git.com>
Fix layout bug
$# See only the diff (no metadata):
$git diff c4d5e~1 c4d5e
- color: white;
+ color: red;
$# Or equivalently:
$git diff c4d5e^!