Git Show Command Explained (View Commit Details, Diff & Files with Examples)

Git Show Command Explained (View Commit Details, Diff & Files with Examples)

What is git show?

git show is used to display detailed information about a Git object, most commonly a commit. It shows the commit message, author, date, and the actual changes (diff) introduced in that commit.

If you simply run:

bash
git show

Git will display details of the latest commit (HEAD).

👉 In simple terms:

git show = “show me what changed in this commit”

Why and When You Should Use git show

If you are already using Git, you might be using commands like:

  • git log → to see commit history
  • git diff → to compare changes

But these do not give a complete picture in one place.

👉 That’s where git show helps.

Use git show when you want:

  • Full details of a commit (message + changes together)
  • To quickly inspect what a commit actually did
  • To debug issues by checking exact changes
  • To review code before merging or deployment

git show vs git log vs git diff

CommandWhat it does
git showShows commit details + changes (all in one)
git logShows commit history only
git diffShows changes between commits or files

👉 If you want everything in one command → use git show


Git Show Command – Quick Cheat Sheet

DescriptionCommand
Show latest commitgit show
Show latest commit using HEADgit show HEAD
Show specific commit detailsgit show <commit-hash>
Show commit in one linegit show --oneline
Show only commit messagegit show -s
Show only diff (changes)git show --patch
Show diff summary (files changed)git show --stat
Show changes without diff contentgit show --name-only
Show file names with statusgit show --name-status
Show specific file from commitgit show <commit>:<file>
Show content of file in last commitgit show HEAD:<file>
Compare file across commitsgit show <commit>:<file>
Show tag detailsgit show <tag-name>
Show commit with short hashgit show --abbrev-commit
Show full commit hashgit show --no-abbrev-commit
Show raw commit datagit show --raw
Show output in email formatgit show --pretty=email
Show detailed author infogit show --pretty=fuller
Show only commit metadatagit show --no-patch
Show multiple commitsgit show <commit1> <commit2>
Show stash changesgit stash show -p
Show object (blob/tree/tag)git show <object-id>
Show changes for last commit onlygit show HEAD~1
Show commit with color diffgit show --color
Show minimal output for scriptsgit show --pretty=format:"%h %s"

Quick Examples

bash
# Show latest commit
git show

# Show specific commit
git show 1a2b3c4d

# Show file from a commit
git show 1a2b3c4d:index.html

# Show only summary
git show --stat

# Show only commit message
git show -s

View Commit Details

Show latest commit (git show HEAD)

To view the latest commit details, including message and changes:

bash
git show HEAD

This is useful when reviewing recent work after making changes using git commit message.

Show specific commit (git show )

To inspect a particular commit:

bash
git show <commit-hash>

You can find commit hashes using git log or explore history with git reflog tutorial.

Show commit summary only

If you only want a quick summary without full diff:

bash
git show --oneline

This gives a concise view similar to commit listings from git list branches.


View Changes in a Commit

Show full diff of a commit

To see complete changes introduced in a commit:

bash
git show <commit-hash>

This combines commit details and diff output, unlike git diff examples which only shows differences.

Show only file changes

To list only files changed in a commit:

bash
git show --name-only

Useful when reviewing modifications after operations like git merge examples.

Show diff stats (insertions/deletions)

To get a summary of changes:

bash
git show --stat

This helps analyze impact before applying changes or during code review workflows.


View File Content from a Commit

Show a specific file from commit

To view a file from a past commit:

bash
git show <commit-hash>:<file>

This is helpful when restoring content or comparing with current state using git restore.

Compare file across commits

To inspect how a file changed over time:

bash
git show <commit-hash>:<file>

For deeper comparison across commits, you can also use git diff examples.


Work with Tags and Objects

Show tag details

To view information about a tag, including the associated commit:

bash
git show <tag-name>

This displays tag metadata, message, and commit details. To learn more about tags, refer to git tag tutorial.

Show Git objects (blob, tree)

You can also inspect low-level Git objects like blobs and trees:

bash
git show <object-id>

For deeper inspection of Git internals, you can compare this with plumbing commands like git cat-file.

Difference between git show and git cat-file

  • git show → human-readable output (commit, diff, message)
  • git cat-file → raw object-level inspection

👉 Use git show for daily workflows and git cat-file for debugging internals.


Customize git show Output (Advanced but High Value)

Use --pretty formats (oneline, full, email)

Customize how commit details are displayed:

bash
git show --pretty=oneline
git show --pretty=full
git show --pretty=email

This helps when formatting logs or reviewing commits.

Show short vs full commit hash

Control how commit hashes are displayed:

bash
git show --abbrev-commit
git show --no-abbrev-commit

This is useful when working with commit history and referencing commits precisely.

Show raw output and patches

To inspect low-level or patch-style output:

bash
git show --raw
git show --patch

Useful for debugging or understanding detailed changes, especially when comparing with tools like git diff examples.


Common Errors and Confusions

git show not working or empty output

This usually happens when:

  • No commits exist yet
  • Incorrect reference is used

Fix by verifying commit history:

bash
git log

invalid commit hash

Occurs when the commit ID is incorrect or incomplete.

Fix:

  • Use git log --oneline to get valid commit IDs
  • Copy the correct hash before running git show

difference between git show and git diff

  • git show → displays commit details + changes
  • git diff → compares changes between commits or working directory

Use git show for inspecting a commit and git diff examples for comparison workflows.


Frequently Asked Questions

1. What does git show do?

The git show command displays detailed information about a commit, including the commit message, author, date, and the changes introduced in that commit.

2. How do I view a specific commit in Git?

You can view a specific commit using git show <commit-hash>, which displays commit details and the associated changes.

3. What is the difference between git show and git diff?

Git show displays commit details along with changes, while git diff is used to compare differences between commits or files.

4. How do I view a file from a previous commit?

You can view a file from a commit using git show <commit-hash>:<file>, which shows the file content at that point in history.

5. Can git show display tags and objects?

Yes, git show can display information about tags, blobs, trees, and other Git objects using their identifiers.

Summary

The git show command is one of the most useful tools for inspecting commits, files, and Git objects in a single step.

In this guide, you learned how to:

  • View commit details and changes
  • Inspect specific files from commits
  • Work with tags and Git objects
  • Customize output for different use cases
  • Troubleshoot common issues

Using git show effectively helps in debugging, reviewing code, and understanding changes quickly without switching between multiple Git commands.


Official Documentation

For more details, refer to the official Git documentation:

Steve Alila

Steve Alila

Specializes in web design, WordPress development, and data analysis, with proficiency in Python, JavaScript, and data extraction tools. Additionally, he excels in web API development, AI integration, and data presentation using Matplotlib and Plotly.