Skip to content

git show: The Universal Object Inspector for CI/CD ​

git show is the swiss army knife of Git inspection. It displays any Git object (commit, tree, blob, tag) in human-readable form. For DevOps, it is the go-to command for CI debugging, artifact verification, audit trails, and patch inspection without a local checkout.

This guide covers every mode of git show, its plumbing-level behavior, and the automation patterns that make it indispensable in CI/CD pipelines.

What it answers ​

"What did that tagged release actually contain?"

"Was the build artifact generated from a clean tree?"

"Which files changed in this merge, and which side won each conflict?"

"Is this CI runner's checkout at the expected commit?"

"What does the raw tree look like for this commit on the deployment target?"

Object type dispatch ​

git show detects the type of the object you pass and renders it accordingly:

Object typeWhat git show displays
CommitLog message, diff against parent (or combined diff for merges)
Treels-tree style listing of the directory
BlobRaw file content
Annotated tagTag object contents + the object it points to
RefDereferences the ref and shows the underlying object

This dispatch is the core of its power. One command handles every object type.

bash
git show HEAD                    # commit: log + diff
git show v2.0.0                  # tag: tag info + the tagged commit
git show main:deploy/config.yaml # blob: file content at that ref
git show main^{tree}             # tree: root directory listing

Commit mode: the diff engine ​

Single parent (normal commit) ​

bash
git show HEAD

Shows the commit message, author, date, and the diff against its parent. Equivalent to:

bash
git log -1 -p HEAD

Merge commit (combined diff) ​

bash
git show <merge-sha>

For a merge commit with multiple parents, git show produces a combined diff. It shows only the lines that differ from all parents. Lines that match any parent are suppressed.

This is the most misunderstood feature of git show. A combined diff does not show everything the merge brought in. It shows only the lines that conflict resolution actively chose:

diff
diff --cc src/config.c
index abc1234,def5678..7890abc
--- a/src/config.c
+++ b/src/config.c
@@@ -10,7 -10,7 +10,11 @@@
      timeout = 30;
      retries = 3;
++    max_connections = 100;
++    enable_metrics = true;

The ++ lines were present in neither parent. The double-column markers (@@@) indicate a combined hunk header. Lines that came from one parent unchanged are not shown.

Controlling combined diff output ​

bash
git show --cc <merge-sha>         # combined diff (default for merges)
git show -m <merge-sha>           # split into separate diffs against each parent
git show -m --first-parent <sha>  # diff only against first parent (mainline)

Use -m in CI when you need the full diff of what a merge commit introduced relative to the branch it merged into:

bash
# In a CI pipeline checking what a PR merge would change
git show -m --first-parent HEAD

Format control ​

bash
git show --format=fuller          # full author/committer info
git show --format="%H %ct %s"     # machine-readable: SHA, timestamp, subject
git show --stat                   # file change stats (no diff)
git show --name-only              # file list only (fastest)
git show --name-status            # file list with change type (A/M/D)
git show --raw                    # raw format (plumbing-compatible)

In CI, prefer --name-status or --raw over --stat when the output feeds into a script:

bash
# List every file changed in the latest commit, with change type
git show --name-status --format="" HEAD
# Output:
# M       src/config.c
# A       src/feature.c
# D       src/old.c

Tag mode: verifying release integrity ​

bash
git show v2.0.0

For an annotated tag, output has three sections:

  1. Tag object. Tagger, date, message, optionally signature
  2. Commit object. The commit the tag points to
  3. Diff. The diff for that commit

For signed tags, the signature grade appears:

tag v2.0.0
Tagger: CI Bot <ci@example.com>
Date:   Mon Nov 10 15:00:00 2026 -0500

Release v2.0.0

-----BEGIN SSH SIGNATURE-----
...
-----END SSH SIGNATURE-----

To see only the tag object (no commit diff):

bash
git show v2.0.0 --no-patch

To verify the tag's signature programmatically and then inspect:

bash
git verify-tag v2.0.0 2>/dev/null && git show v2.0.0 --no-patch --format="%H %ct"

Tree mode: inspecting directory state ​

bash
git show HEAD^{tree}

Output is identical to git ls-tree HEAD:

100644 blob a1b2c3d    src/main.c
100644 blob e5f6a7b    src/utils.c
040000 tree d4e5f6a    src/lib

Use tree mode in CI to check for unexpected files in a commit without checking it out:

bash
# Check that no .env files were committed
git show HEAD^{tree} -- src/ | grep -c "\.env$" && exit 1

Blob mode: reading file content at a specific revision ​

bash
git show main:deploy/values.yaml

Renders the raw file content. This is the fastest way to read a file from any commit or branch without switching branches:

bash
# Compare a config file between two branches without checkout
diff <(git show main:config.yaml) <(git show feature:config.yaml)
bash
# Extract a file from a tag into a CI artifact
git show v2.0.0:CHANGELOG.md > /tmp/artifacts/CHANGELOG.md

CI/CD automation patterns ​

Verify checkout integrity ​

After a shallow or partial clone in CI, verify the checkout matches the expected commit:

bash
git show -s --format="%H" HEAD
# Compare with the expected SHA from the CI trigger payload

The -s (or --no-patch) flag suppresses the diff, making this fast even in large repos.

Audit what a tag points to before deployment ​

bash
#!/bin/bash
# deploy.sh -- verify the tag before deploying
TAG="${1:?usage: $0 <tag>}"
git fetch --tags origin "$TAG"
git verify-tag "$TAG" 2>/dev/null || { echo "Tag $TAG is not signed"; exit 1; }
COMMIT=$(git show --no-patch --format="%H" "$TAG")
echo "Deploying $TAG at commit $COMMIT"

Combined diff for merge validation ​

In a CI pipeline that runs on pull request merge commits, check that the merge did not silently discard changes:

bash
# This merge commit's combined diff should match the PR branch diff
git show --format="" HEAD > /tmp/merge-diff.txt
git diff HEAD~1...HEAD^2 > /tmp/pr-diff.txt  # diff between first parent and second parent
diff <(sort /tmp/merge-diff.txt) <(sort /tmp/pr-diff.txt)

Any significant divergence means the merge introduced or dropped content beyond what was in the PR.

Machine-readable output for dashboards ​

bash
# CI metrics emission
echo "commit_sha=$(git show -s --format='%H')"
echo "commit_time=$(git show -s --format='%ct')"
echo "commit_author=$(git show -s --format='%an')"
echo "files_changed=$(git show --name-only --format='' HEAD | wc -l)"
echo "lines_added=$(git show --numstat --format='' HEAD | awk '{s+=$1} END {print s}')"

Object existence check ​

bash
git show <sha> --quiet 2>/dev/null && echo "Object exists" || echo "Object missing"

The --quiet flag suppresses all output and uses the exit code. Useful in CI to verify a referenced object exists in a partial clone before trying to fetch it.

Performance characteristics ​

OperationCostNotes
git show -s --format="%H" HEADNegligibleReads HEAD ref + single commit object
git show --name-only HEADFastReads commit + tree object
git show HEAD (with diff)ModerateComputes diff against parent
git show <merge-sha> (combined diff)HigherComputes diff against all parents
git show main:large-file.binModerateReads and outputs the blob
git show HEAD^{tree}FastSame as ls-tree

For CI pipelines, prefer --name-only or -s over full diffs when you only need metadata. Use --format="" to suppress the commit header when piping to scripts.

Edge cases ​

Showing a range ​

bash
git show HEAD~3..HEAD

Shows each commit in the range individually. Equivalent to git log -p. Useful for a quick review of the last N commits.

Showing the same commit from different refs ​

bash
git show main~2
git show origin/main~2

These produce the same output if main and origin/main are at the same point. If they have diverged, origin/main~2 shows the remote's history, which may differ from the local branch's.

Object not found in partial clone ​

In a partial clone with promisor remotes, git show triggers a fetch-on-demand for missing objects. This can cause unexpected latency in CI:

bash
# Check if the object is local before showing
git cat-file -e <sha> 2>/dev/null || echo "Object not local. Will trigger fetch"

Binary files ​

git show outputs binary content raw. Pipe through file - to detect type, or use --textconv to apply filter drivers:

bash
git show HEAD:image.png | file -
git show HEAD:config.jsonc | head -20   # text files display fine

Empty commits ​

bash
git show --allow-empty <empty-commit-sha>

Without --allow-empty, git show prints the commit metadata but notes "no diff."

CommandBest forgit show advantage
git log -pMultiple commits in sequenceSingle-commit focus, no pager needed in CI
git diff HEAD~1..HEADRaw diff, no commit metadataIncludes full commit header + signature
git cat-file -pPlumbing, no formattingHuman-readable output, auto-dispatch by type
git ls-treeDirectory listing onlyTree mode = same output, plus other object types
git verify-commitSignature verification onlyIncludes verification + full display

In CI scripts, prefer git show over git log -p when examining a single commit: the output is self-contained (includes the commit header) and does not paginate.

Pitfalls ​

PitfallWhy it bitesWorkaround
Combined diff hides unchanged-parent linesYou think a merge changed nothing, but it really brought in code from one parentUse git show -m --first-parent or compare git diff HEAD~1 HEAD^2
git show with a blob path matches the ref pattern firstgit show main:path works; git show main:path:sub failsUse git show ref:path syntax; colons in filenames must be escaped
Large blobs fill CI logsOutput of a 100MB binary corrupts the logCheck file size first with git cat-file -s, or use --format= to skip blob mode
Promisor fetch-on-demandCI pipeline stalls mid-step fetching missing objectsRun git fetch --all first, or check git cat-file -e before git show
git show HEAD -- path is not the same as git show HEAD:pathFirst form filters the diff to a path; second reads the file at that path directlyKnow which mode you need. They produce completely different output
Piped output lacks trailing newline in --format=Concatenated strings lose their last newlineAdd echo after the command or include \\n in the format string

Quick reference ​

bash
git show HEAD                       # Last commit with diff
git show -s HEAD                    # Last commit metadata only (no diff)
git show --name-only HEAD           # Files changed (fast)
git show --stat HEAD                # Change stats
git show --format="%H %s" HEAD      # Machine-readable format
git show v2.0.0                     # Tag object + tagged commit
git show v2.0.0 --no-patch          # Tag metadata only
git show main:deploy/values.yaml    # File content at ref
git show HEAD^{tree}                # Root tree listing
git show HEAD --quiet               # Exit code only (exists?)
git show -m --first-parent <merge>  # Merge diff against mainline
git show --name-status --format=""  # Machine-readable file list
git show HEAD~3..HEAD               # Range of commits

Git Master — Git Reference for Every Skill Level