Menu
Coddy logo textTech

Git Show

Part of the Version Control section of Coddy's Terminal journey — lesson 17 of 58.

git show displays a single commit: its message, metadata, and the diff of what it changed. With no arguments, it shows the most recent commit:

git show

You can also pass a specific commit ID:

git show a1b2c3d

Or use a relative reference like HEAD~1 to mean "one commit before HEAD":

git show HEAD~1

For just the message of a commit (no diff), pass --no-patch together with a format string:

git show --no-patch --pretty=%s HEAD

This is useful in scripts where you only care about the subject line, not the full content.

challenge icon

Challenge

Easy

The folder contains plan.md. Initialize the repo and create two commits:

  1. Add plan.md with the message Add plan.
  2. Append the line step 1 to plan.md, stage it, and commit with the message Add first step.

Then print just the subject of the previous commit (one before HEAD) using git show --no-patch --pretty=%s HEAD~1.

Cheat sheet

git show displays a commit's message, metadata, and diff:

git show          # most recent commit
git show a1b2c3d  # specific commit ID
git show HEAD~1   # one commit before HEAD

For just the subject line (no diff), use --no-patch with a format string:

git show --no-patch --pretty=%s HEAD

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control