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.yamlIn 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
git log Command: Inspect History in CIgit log shows commit history. Reference for --oneline, -n, and --format to extract commit messages and author…
git diff Command: Detect Changes in CIgit diff shows changes between commits or the working tree. Reference for --name-only, --stat, and --exit-cod…
git archive Command: Export Trees in CIgit archive exports a tree as a tar or zip. Reference for --format, --prefix, and pathspecs to build clean so…
git blame Command: Attribute Lines in CIgit blame shows which commit last changed each line. Reference for -L, --porcelain, and -w to attribute lines…