Synopsis
git show [<options>] [<object>...]
Description
The git show command displays information about Git objects: commits (with diff), tags (annotation + tagged object), trees (file listing), or blobs (file contents). Without arguments, it shows the most recent commit. With a path argument, it displays the file as it existed at a specific revision.
git show is the go-to tool for inspecting a single commit in detail. Unlike git log -1 -p, it formats both annotated tags and tree listings naturally, making it useful for examining release tags or extracting historical file contents.
In day-to-day use, git show integrates closely with shell aliases, editor plugins, and continuous integration. Power users often add aliases that combine flags they always pass, or wrap the command in scripts that enforce team conventions. Output formatting can be customized via Git config — pretty formats, color schemes, and pager behavior are all tunable. When something goes wrong, the first diagnostic step is usually to re-run the command with GIT_TRACE=1 in the environment, which reveals the underlying plumbing calls. For unusual situations, the --help output (git show --help) opens the full manual page with details on every option, including those rarely used in casual workflows but essential for debugging or scripting at scale.
Understanding how git show interacts with the rest of Git's data model — the object database, the index, refs, and the working tree — pays dividends. Each command operates on some subset of these pieces, and knowing which it touches helps predict outcomes and recover from mistakes. Reading the official Git documentation alongside hands-on practice in a throwaway repository is the fastest way to internalize the nuances. Most production issues with Git stem from one of three causes: surprising default behavior, partial network operations, or rewriting history that was already shared. A working mental model of git show's side effects helps avoid all three.
Common Options
| Option | Description |
|---|---|
--stat | Add a diffstat summary. |
--name-only | List only changed file names. |
--pretty=<fmt> | Choose format: oneline, short, full, custom. |
-s, --no-patch | Suppress the diff. |
--show-signature | Verify and display GPG signatures. |
--word-diff | Highlight changes at the word level. |
Examples
git show HEAD
# Latest commit with diff
git show v2.0.0
# Show an annotated tag
git show HEAD:src/main.c
# Display the file as it was at HEAD
git show --stat abc123
# Just the diffstat for a specific commit
Common Mistakes
Confusing git show HEAD~1 (one commit before HEAD) with git show HEAD^1 (first parent of HEAD) — they're equivalent on linear history but differ on merges. Also note git show HEAD:file uses a colon, not a space, to specify a file at a revision.
Related Commands
git log, git diff, git cat-file, git blame