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 showYou can also pass a specific commit ID:
git show a1b2c3dOr use a relative reference like HEAD~1 to mean "one commit before HEAD":
git show HEAD~1For just the message of a commit (no diff), pass --no-patch together with a format string:
git show --no-patch --pretty=%s HEADThis is useful in scripts where you only care about the subject line, not the full content.
Challenge
EasyThe folder contains plan.md. Initialize the repo and create two commits:
- Add
plan.mdwith the messageAdd plan. - Append the line
step 1toplan.md, stage it, and commit with the messageAdd 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 HEADFor just the subject line (no diff), use --no-patch with a format string:
git show --no-patch --pretty=%s HEADTry it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore