W3docs

git show

Learn the git show command to inspect commits, tags, and individual files at any revision. See useful options and examples.

Definition

The git show command displays details about a Git object — most often a commit. For a commit it prints the log message together with the full diff of what changed, giving you a complete picture of a single revision. It can also reveal tags, trees, and the contents of a file as it existed at any point in history.

Showing a commit

With no arguments, git show displays the most recent commit: its author, date, message, and the changes it introduced.

git show

To inspect any other commit, pass its hash, a branch name, or a relative reference:

git show a1b2c3d
git show HEAD~2

The output combines what you would get from git log and git diff for that one commit.

Viewing a file at a specific revision

A powerful trick is to print a file exactly as it looked in a given commit, without checking anything out. Use the <commit>:<path> syntax:

git show HEAD~3:src/index.js

This streams the old version of index.js to your terminal, leaving your working tree untouched — ideal for comparing or copying a snippet from the past.

Inspecting tags

When you point git show at an annotated tag, it prints the tag message and tagger information, then the commit the tag refers to:

git show v1.0.0

This is the quickest way to see who created a release tag and what it points at. See git tag for creating them.

Common options

CommandDescription
git showShows the latest commit with its full diff.
git show <commit>Shows a specific commit by hash, branch, or reference.
git show <commit>:<file>Prints the contents of a file as of that commit.
git show --stat <commit>Summarizes which files changed and by how many lines.
git show --name-only <commit>Lists only the names of the changed files.
git show <tag>Shows a tag's metadata and the commit it points to.

git show vs git log and git diff

These three commands overlap but serve different needs. git log walks a range of commits and is built for browsing history. git diff compares two arbitrary states. git show zooms in on one object and tells you everything about it — making it the natural choice when you already know which commit you care about.

Practice

Practice

What can 'git show' do?