Tour of Git
Advanced Git / Lesson 5.9

git show — Inspecting Commits

git show displays the details of a specific commit — its message, author, and the exact changes (diff) it introduced. While git log gives you the overview, git show gives you the full picture of a single commit.

Basic Usage

git show

With no arguments, it shows the most recent commit (HEAD). The output includes:

commit a1b2c3d4e5f6...
Author: Alice <[email protected]>
Date:   Mon Jan 15 10:30:00 2024

    Add user authentication

diff --git a/auth.js b/auth.js
new file mode 100644
--- /dev/null
+++ b/auth.js
@@ -0,0 +1,5 @@
+function authenticate(user) {
+  // verify credentials
+  return true;
+}

Showing a Specific Commit

git show e4f5g6h
git show main
git show v1.0

You can pass any ref — a SHA, branch name, or tag.

Reading the Output

The output has two parts:

1. Commit Metadata

  • Commit SHA — the full hash
  • Author — name and email
  • Date — when it was created
  • Message — the commit message (indented)

2. Diff

Shows exactly what changed:

  • Lines starting with + were added
  • Lines starting with - were removed
  • @@ headers show the line numbers affected

Useful Variations

CommandShows
git show HEADLatest commit
git show HEAD~1Previous commit
git show <sha>Specific commit
git show <branch>Latest commit on a branch
git show <tag>Tagged commit

git show vs git log vs git diff

CommandPurpose
git logList multiple commits (overview)
git show <commit>One commit's metadata + diff
git diff A BDifferences between two points

Try it!

  1. View the latest commit in detail: git show
  2. View the log to find an older commit: git log --oneline
  3. Show a specific commit: git show <sha> (use a SHA from the log)
  4. Compare: git show HEAD~1 to see the previous commit

Key Points

  • git show displays a commit's full details and diff
  • With no arguments, it shows HEAD
  • Accepts any ref: SHA, branch, tag, HEAD~N
  • The diff shows exactly what that single commit changed
  • Great companion to git blame — blame finds the SHA, show explains it
🎯

Goal

Use git show to inspect commit details and diffs

Terminal
$

No commits yet. Run `git init` and create your first commit.