Git Show: Reading Committed Snapshots
Use git show to inspect committed objects, commit metadata, and the changes introduced by a commit without confusing object inspection with state comparison.
Basic
What `git show` actually shows
`git show` is an inspection command for Git objects. When the object is a commit, the normal form shows the commit metadata, its log message, and the textual changes introduced by that commit. It does not create a new commit or alter the working tree or index.
git show
git show HEADQuick check
When the argument is a commit, what does the normal form of `git show` display?
git show HEADgit show HEAD
A commit is a snapshot with a parent relationship
For a normal non-merge commit, the patch shown by `git show <commit>` describes the difference introduced by that commit relative to its parent. This is different from `git diff`, where you explicitly choose the comparison states. `git show` starts from an object and explains what that object contains or, for a commit, what change it introduces.
git log --oneline
git show HEAD
git show HEAD~1Quick check
For an ordinary non-merge commit, relative to what does its default patch describe the introduced change?
git show HEADgit show HEAD
Use an explicit commit when history matters
Using an explicit revision makes the inspection reproducible: `git show <commit>` asks Git to show that particular object rather than relying on the default `HEAD`. A short object name such as `HEAD~1` is a revision expression resolved by Git. The revision syntax itself belongs to the later revision-selection curriculum; here it is used only to select an already-known snapshot.
git show HEAD
git show HEAD~1Quick check
Why is `git show <commit>` preferable when you need to inspect a specific historical snapshot?
git show HEAD~1git show HEAD~1
Separate commit content from commit metadata
The default output combines commit information with its patch. Options can narrow what you inspect. `--no-patch` suppresses the diff portion, while `--format` controls the displayed commit information. This is useful when the question is about who made the commit, its message, or its object identity rather than the file changes.
git show --no-patch HEAD
git show --format=fuller --no-patch HEADQuick check
Which option suppresses the patch portion of `git show`?
git show --no-patch HEADgit show --no-patch HEAD
Inspect the committed version of a path
A path can be supplied after the revision and `--` to limit the displayed commit changes to that path. This is an observation of the selected commit; it does not read the current working-tree version as its source. Keeping the revision before `--` and the path after it makes the intended boundary explicit.
git show HEAD -- README.mdQuick check
What does `git show HEAD -- README.md` do?
git show HEAD -- README.mdgit show HEAD -- README.md
Do not confuse `git show` with `git diff`
The commands answer related but different questions. `git diff` is primarily a comparison between selected states. `git show <commit>` starts from a selected Git object and, for a commit, reports that commit and the change it introduced. Neither command mutates repository state.
git diff HEAD~1 HEAD -- README.md
git show HEAD -- README.mdQuick check
Which statement distinguishes the two commands?
git diff HEAD~1 HEAD -- README.md
git show HEAD -- README.mdgit show HEAD -- README.md
Practice what you learned
Use the dedicated Git code-completion exercise for this lesson.
Official-source boundary
This lesson is grounded only in the official Git project documentation for `git show` and Git revision selection. The current official documentation baseline is Git 2.56.0. The `git-show` documentation records no changes from Git 2.46.1 through 2.47.3, matching the local Git 2.47.3 verification executable. Revision syntax is used here only at the level required to select known commits; full revision-expression mastery remains a later curriculum owner.
Thanks for your feedback.
Mark this learning resource complete to track your learning progress.