← Back to Git Course | Chapter 2: Basic Commands | Lesson 13 of 18

Git show Command

Showing the Last Commit

git show with no arguments displays everything about your most recent commit -- author, date, full message, and the exact patch (line-by-line code changes) it introduced -- in one combined view.

Example: Showing the Last Commit

bash
git show

Showing a Specific Commit

Passing a specific commit hash or tag name, like git show a1b2c3d, lets you inspect any point in your project's history the same way, not just the latest commit.

Example: Showing a Specific Commit

bash
git show a1b2c3d

Showing a File at a Specific Commit

git show <commit>:<path/to/file> prints a file's exact contents as they existed at that specific commit, without checking out that commit or disturbing your current branch or working files at all.

Example: Showing a File at a Specific Commit

bash
git show a1b2c3d:path/to/file.txt

Customizing the Output Format

If you only care about which files changed rather than the full line-by-line patch, git show --stat swaps the detailed diff for a compact summary of insertion/deletion counts per file.

Example: Customizing the Output Format

bash
git show --stat

Showing File Names and Status

git show --name-only goes even further, listing just the filenames that were added, modified, or deleted in that commit -- useful for a quick glance at a commit's scope before diving into the actual changes.

Example: Showing File Names and Status

bash
git show --name-only

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.