LinuxCommandLibrary

git-show

Show git object (commit, tag, blob)

TLDR

Show information about the latest commit (hash, message, changes, and other metadata)

$ git show
copy

Show information about a specific commit, tag, or branch (such as HEAD for the latest commit)
$ git show [commit|tag|branch]
copy

Show only the list of added, renamed, or deleted files
$ git show --summary [commit]
copy

Show information about the 3rd commit from the HEAD of a branch
$ git show [branch]~[3]
copy

Show a commit's message in a single line, suppressing the diff output
$ git show --oneline [[-s|--no-patch]] [commit]
copy

Show only statistics (added/removed characters) about the changed files
$ git show --stat [commit]
copy

Show a simplified list of all files changed in a commit (modified, added, and deleted)
$ git show --name-only [commit]
copy

Show the contents of a file as it was at a given revision (e.g. branch, tag, or commit)
$ git show [revision]:[path/to/file]
copy

SYNOPSIS

git show [options] [object...]

PARAMETERS

-p, --patch
    Generate patch (default for commits)

-s, --no-patch
    Suppress diff output

--stat
    Show diffstat instead of full patch

--numstat
    Show number of added/removed lines

--name-only
    Show only names of changed files

--name-status
    Show names with status (A/D/M)

--pretty[=format], --format[=format]
    Pretty-print commit headers

--oneline
    One line per commit

-n num, --max-count=num
    Limit to first num commits

--abbrev-commit
    Use short commit hashes

--graph
    ASCII graph of history

--color[=when]
    Enable colored output

--notes[=ref]
    Show notes for object

-t, --tree
    Show tree only, no objects

--raw
    Raw diff output format

DESCRIPTION

git show displays the contents of Git objects such as commits, trees, blobs, or tags. For commits, it shows the commit metadata (author, date, message) followed by a unified diff of changes by default. Trees list directory contents, blobs show raw file data, and tags display tag messages and pointed objects.

Without arguments, it shows the latest commit on the current branch. Specify a revision like HEAD~1 or a hash to view others. It's ideal for quick inspections during development, debugging changes, or reviewing pull requests.

Output can be customized with options for stats only (--stat), no diffs (-s), custom formats (--pretty), or decorations (--graph). Supports piping to grep or less for filtering. Unlike git log, it focuses on one object; unlike git diff, it includes commit info. Handles annotated tags fully, including signatures if present.

Common workflow: git show --stat for change summaries, git show <commit>:<path> for historical file versions.

CAVEATS

Interprets objects with formatting; use git cat-file for raw dumps. Diffs assume text files; binaries shown as-is.

EXAMPLES

git show HEAD - Latest commit with diff
git show --stat abc123 - Stats for commit
git show v1.0 - Tag details
git show HEAD:README.md - File at HEAD

OBJECT PATHS

Use commit:path for historical files, e.g., git show main:src/main.c

HISTORY

Introduced in Git 0.99 (2005) by Linus Torvalds as core porcelain command; evolved with formatting options in Git 1.0+ for better usability.

SEE ALSO

git log(1), git diff(1), git cat-file(1), git rev-list(1)

Copied to clipboard