Skip to content
Latchkey

git show Command: Inspect Objects in CI

git show prints the details of a Git object: a commit and its diff, a tag, or a file at a revision.

CI uses git show to extract a commit message for a release note or to read a file as it existed at another ref without checking it out.

Common flags

  • <commit> - show a commit message and its diff
  • -s / --no-patch - suppress the diff and show only the message
  • --format=<fmt> / --pretty=<fmt> - control the output format
  • <rev>:<path> - print the contents of a file as of a revision
  • --stat - summarize changed files instead of the full patch
  • --name-only - list only the files a commit touched

Example

shell
# Grab the subject line of the triggering commit
SUBJECT="$(git show -s --format=%s HEAD)"
# Read a config file as it was on main, without checkout
git show origin/main:config/app.yaml

In CI

git show -s --format=%s HEAD is the compact way to pull a commit subject for notifications. The <rev>:<path> form lets a step compare or read a file from another branch without switching the working tree.

Key takeaways

  • git show -s --format=%s extracts just a commit message for release notes or alerts.
  • The <rev>:<path> syntax reads a file from any ref without a checkout.
  • Add --stat or --name-only when you only need the list of touched files.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →