Skip to content
LatchkeyLatchkey home

git show: Usage, Options & Common CI Errors

git show prints one object - usually a commit and its diff - in detail.

Use git show to inspect a single commit, see a file at a past revision, or read a tag message.

What it does

git show displays the metadata and contents of an object. For a commit it shows the log message and the diff; for a tag, the tag message; for a blob, its contents.

Common usage

Terminal
git show <sha>
git show HEAD --stat
git show HEAD:path/to/file        # file contents at HEAD
git show v1.2.0                   # tag + its commit
git show --name-only <sha>

Options

FlagWhat it does
--statShow a diffstat instead of the full diff
--name-onlyList changed files only
-s / --no-patchSuppress the diff (metadata only)
<rev>:<path>Show a file as of a revision

Common errors in CI

fatal: bad revision 'X' or fatal: ambiguous argument 'X': unknown revision - the SHA/ref does not exist (often truncated, or absent in a shallow clone). Verify the ref with git rev-parse, and remember <rev>:<path> needs an exact in-repo path.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

git show: Usage, Options & Common CI Errors?
Use git show to inspect a single commit, see a file at a past revision, or read a tag message.
What it does?
git show displays the metadata and contents of an object. For a commit it shows the log message and the diff; for a tag, the tag message; for a blob, its contents.
Common errors in CI?
fatal: bad revision 'X' or fatal: ambiguous argument 'X': unknown revision - the SHA/ref does not exist (often truncated, or absent in a shallow clone). Verify the ref with git rev-parse, and remember <rev>:<path> needs an exact in-repo path.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card