git-show
Show git object (commit, tag, blob)
TLDR
Show information about the latest commit (hash, message, changes, and other metadata)
Show information about a specific commit, tag, or branch (such as HEAD for the latest commit)
Show information about the 3rd commit from the HEAD of a branch
Show a commit's message in a single line, suppressing the diff output
Show only statistics (added/removed characters) about the changed files
Show a simplified list of all files changed in a commit (modified, added, and deleted)
Show only the list of added, renamed or deleted files
Show the contents of a file as it was at a given revision (e.g. branch, tag or commit)
SYNOPSIS
git show [options] [object...]
PARAMETERS
object
The object(s) to show. This can be a commit hash, a branch name, a tag name, or a path within a tree (e.g., HEAD:path/to/file.txt). If omitted, it defaults to HEAD.
-s, --no-patch
Suppress the diff output. Only show the commit log message (for commits) or raw object content (for other types).
-p, --patch
Generate a patch (diff). This is the default when showing a commit object.
--pretty[=format]
Pretty-print the commit log message in a user-specified format. Common formats include oneline, short, medium, full, fuller, email, raw, format:
--stat
Generate a diffstat output. This shows a summary of changes: files changed, insertions, and deletions.
--name-only
Show only the names of the files that were changed.
--name-status
Show only the names and status (Added, Copied, Deleted, Modified, Renamed, etc.) of changed files.
--oneline
A shorthand for --pretty=oneline --abbrev-commit, displaying each commit on a single line.
--decorate[=auto|short|full|no]
Show ref names (branches, tags) that point to the shown commit.
--notes[=ref]
Show notes (if any) associated with the commit.
--color[=when]
Colorize the output. when can be always, never, or auto.
--unified[=n]
Generate diffs with n lines of context instead of the default 3.
-w, --ignore-all-space
Ignore whitespace when comparing lines.
--binary
In addition to --patch, output a binary diff that can be applied with git-apply.
--diff-filter=filter
Limit the files shown in the diff output to those matching the specified filter (e.g., A for Added, D for Deleted, M for Modified, R for Renamed).
DESCRIPTION
The git-show command is used to display various types of Git objects, including
commits, trees, blobs, and tags.
When given a commit object, it typically shows the log message and the diff that introduces the changes of that commit.
For a tree object, it lists the contents of the directory.
For a blob (file content) object, it prints the raw content of the file.
For an annotated tag object, it shows the tag message and the object it points to.
It's a versatile command that provides a human-readable way to inspect the state and history of your repository at different points, often used for quickly reviewing changes introduced by a specific commit or examining file contents from the past without checking them out.
CAVEATS
When showing a merge commit, git-show by default shows a combined diff against its first parent. To see the diff against other parents or a combined diff, additional --diff-merges options are required.
Binary files are usually represented as "Binary files differ" in the output, unless --text or --patch-with-binary is used to force textual or binary diffs.
COMMON USAGE EXAMPLES
git show HEAD: Show the latest commit on the current branch.
git show <commit-hash>: Display details of a specific commit.
git show <branch-name>: Show the tip commit of a named branch.
git show <tag-name>: Show an annotated tag object and the commit it points to.
git show <commit-hash>:path/to/file.txt: Display the content of a specific file at a given commit.
git show --stat <commit-hash>: Show a summary of changes for a commit without the full diff.
git show --pretty=oneline --abbrev-commit <commit-hash>: Display a commit on a single line with an abbreviated hash.
OBJECT TYPES DISPLAYED
git-show can display information about four primary Git object types:
Commit objects: Shows commit message, author, date, and diff.
Tree objects: Lists the names and modes of the files and subdirectories contained within that tree.
Blob objects: Displays the raw content of the file (blob).
Tag objects: For annotated tags, shows the tag message, tagger, and the object it points to (usually a commit).
HISTORY
The git-show command has been a fundamental part of Git since its early days, serving as a high-level interface to inspect objects, building upon lower-level commands like git-cat-file. Its core functionality for displaying commit details and diffs has remained consistent, with ongoing enhancements focused on adding more options for output formatting and diff presentation.
SEE ALSO
git-log(1), git-diff(1), git-cat-file(1), git-rev-parse(1)