# git show Command: Inspect Objects in CI

> git show displays commits, tags, and file contents at a revision. Reference for printing a commit message or a file from another ref in CI scripts.

Source: https://latchkey.dev/learn/command-reference/git-show-command-reference  
Updated: 2026-06-26

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.

## 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
```

> `git rev-parse --abbrev-ref HEAD` returns the literal string `HEAD` on a detached checkout rather than a branch name. On GitHub Actions read `github.ref_name` instead; the git command cannot know what it was checked out for.

## FAQ

### git show Command: Inspect Objects in CI?

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.

### 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
