git show Command Guide
Show various types of objects
Dai Aoki
CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm
Quick Reference
Commits
git showShow last commitgit show <commit>Show specific commitgit show HEAD~2Show 2 commits agoFiles
git show <commit>:<file>Show file at commitgit show :/<pattern>Show matching commitOptions
--statShow file stats--name-onlyShow file names only-qSuppress diff outputDownloadable Image Preview
Basic Usage
The git show command displays detailed information about Git objects - commits, tags, trees, and blobs.
# Show the last commit with diff
git show
# Show a specific commit
git show abc1234
# Show with statistics
git show --statShowing Commits
# Show HEAD (most recent commit)
git show HEAD
# Show commit relative to HEAD
git show HEAD~1 # Previous commit
git show HEAD~3 # 3 commits ago
git show HEAD^ # Parent of HEAD
# Show by commit hash
git show abc1234
# Show commit matching message pattern
git show :/fix # First commit with "fix" in message
# Show commit info without diff
git show -q abc1234
git show --quiet abc1234
# Show only the commit message
git show -s --format=%B abc1234Showing File Contents
# Show file at specific commit
git show abc1234:src/app.js
# Show file at HEAD
git show HEAD:package.json
# Show file from 3 commits ago
git show HEAD~3:config.json
# Show file from another branch
git show feature:src/utils.js
# Show only certain file's changes in commit
git show abc1234 -- src/app.jsShowing Tags
# Show annotated tag (includes message)
git show v1.0.0
# Show tag and its commit
git show --stat v1.0.0
# List files at a tag
git show v1.0.0 --name-only| Option | Description |
|---|---|
| --stat | Show file change statistics |
| --name-only | Show only names of changed files |
| --name-status | Show names and status (A/M/D) |
| -q, --quiet | Suppress diff output |
| --format=<format> | Custom output format |
Practical Examples
# Review last commit before pushing
git show
# Quick look at commit summary
git show --stat HEAD
# Get old version of a file
git show v1.0.0:src/config.js > old-config.js
# See what files changed in a commit
git show --name-only abc1234
# Check what was merged
git show --stat <merge-commit>
# View remote branch's last commit
git show origin/mainFrequently Asked Questions
What is the difference between git show and git log?
"git show" displays detailed information about a single commit (with diff). "git log" displays a list of commits. Use show for details, log for history.
How do I see a file from a specific commit?
Use "git show <commit>:<path/to/file>". For example: "git show HEAD~3:src/app.js" shows app.js as it was 3 commits ago.
How do I show only the commit message without the diff?
Use "git show -q <commit>" or "git show --quiet <commit>" to suppress the diff output and show only the commit metadata.
Can I show multiple commits at once?
Yes, specify multiple commits: "git show abc123 def456". Or use a range with git log instead for better formatting.
Summary
git show provides detailed views of commits, files, and tags. It's perfect for inspecting specific changes in your repository.
Quick Reference
git show- Show last commitgit show <commit>- Show specific commitgit show <commit>:<file>- Show file at commitgit show --stat- Show with statistics
Official Documentation
For authoritative information, refer to the official documentation: