Skip to content

Git Show


What Will We Learn?

Purpose of using git show and common daily useful patterns.

What is git show For?

git show is basically for inspecting the contents and changes of commits, tags and other git objects. By default, git show runs on the latest commit and shows:

  • Commit Metadata (Commit hash, Author, Date, Commit message)
  • Diff Output (Changes introduced in that commit)

Note

git show will show diff output of all the files related to the particular commit unless you ask for specific file like: git show main.c

Common git show Patterns

Inspect Specific Commit

Pass the specific commit hash. For example:

git show <commit-hash>

Inspect the Contents of File

You can view the whole contents of particular files at the specific commit. For example:

git show HEAD~1:file.c

It will show the content of file.c in the commit prior to the current.

Files Included in Particular Commit

You can list the files includd in the particular commit using --name-only option:

git show <commit-hash> --name-only

Tip

The above command will also show the commit metadata along with the name of files. You can supress the commit metadata using --pretty="" option. See the example here: git show --pretty="" --name-only HEAD~2

Show Commit Without the Patch

Display only the commit information without showing the diff:

git show --no-patch <commit-hash>

This is useful when you only want to inspect the commit metadata, such as the author, date, and commit message.

Compare Any Git Object

git show accepts more than just commit hashes. You can inspect objects referenced by:

  • Branches (main, feature/login)
  • Tags (v2.1.0)
  • HEAD and relative references (HEAD~2, HEAD^)
  • Stash entries (stash@{0})

For example:

git show feature/login

or

git show stash@{0}

git show with Diff Options

By default, git show displays the commit metadata followed by the patch (diff) introduced by the commit. You can customize how the diff is displayed using several options.

Show Only the Diff

Suppress the commit metadata and display only the patch:

git show --pretty="" HEAD

Show Summary of Changes

Display a compact summary of the files changed, including the number of insertions and deletions:

git show --stat HEAD

Show File Names Only

List only the names of files changed in the commit:

git show --name-only HEAD

Show File Names and Status

Display the names of changed files along with their status:

  • A – Added
  • M – Modified
  • D – Deleted
  • R – Renamed
  • C – Copied
git show --name-status HEAD

Filter File Names by Status

This is different from --name-status. You can use --diff-filter=<status> to filter file by status. For example:

git show --diff-filter=M abc123

This only shows changes for Modified(M) in abc123 commit. Example output is:

commit abc123a0e7d2aef6cbc45e09ca4eca62ecc4cfc4 (HEAD -> master)
Author: Jane Bro <[email protected]>
Date:   Fri Jul 31 18:33:19 2026 +0545

    Configuration: set `draft: false` for `git-log`

diff --git a/git-log.md b/git-log.md
index 4635bb2..3232623 100644
--- a/git-log.md
+++ b/git-log.md
@@ -1,6 +1,6 @@
<stripped>

A common pattern is to view file names only along with status. Use with --name-only for that. Also supress the commit metadata with --pretty="" or --format="":

git show --diff-filter=M --format="" --name-only abc123 

Now the output will be:

git-log.md

Show Word-Level Changes

Highlight changes at the word level instead of entire lines:

git show --word-diff HEAD

This is especially useful when reviewing documentation or source code where only a few words have changed.

Ignore Whitespace Changes

Ignore whitespace-only differences when displaying the patch:

git show -w HEAD

Show Changes for a Single File

Display only the changes made to a specific file in the commit:

git show HEAD -- src/main.c

Show Colored Moved Lines

Highlight moved code to make refactoring easier to review:

git show --color-moved HEAD

Show Combined Diff for Merge Commits

Display the combined diff of a merge commit:

git show --cc <merge-commit>
Last updated on