Git commands

git show

git show: show the details of a specific commit, tag, or other object.

The git show command is used to display detailed information about a specific Git object, most commonly a commit. It shows the commit metadata (author, date, message) along with the diff of changes introduced by that commit. This command is particularly useful when you want to examine what exactly changed in a specific commit without having to compare it manually with its parent.

By default, git show displays the most recent commit on the current branch. You can specify any commit hash, branch name, tag, or other Git reference to show details for that specific object. The output includes the commit message, author information, timestamp, and a unified diff showing all the changes made in that commit.

When the output of git show is too long to fit on one screen, your terminal will enter pager mode. You can scroll through the output using the and arrow keys (or PageUp and PageDown for faster scrolling). To exit pager mode, press q.

Examples

Show the details of the most recent commit:

git show

Show the details of a specific commit by its hash:

git show 1a2b3c4d

Show only the commit message and metadata without the diff:

git show --no-patch

Show changes to a specific file in a commit:

git show 1a2b3c4d -- path/to/file.js

-- is a special separator that tells Git to treat everything after it as a file path, even if it looks like a branch or tag name. It's completely optional, but useful when you want to avoid ambiguity between file names and Git references.

Show only the names of files that were changed in a commit:

git show --name-only

Understanding the output

When you run git show on a commit, the output typically looks like this:

Result:
commit 1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p7q8r9s0t
Author: John Doe <john.doe@example.com>
Date: Mon Jan 15 14:30:25 2024 -0500
Fix navigation bug in mobile view.
Updated CSS media queries to properly handle small screens.
diff --git a/src/components/Navigation.js b/src/components/Navigation.js
index 1c2s3z5..4f5g6h7 100644
--- a/src/components/Navigation.js
+++ b/src/components/Navigation.js
@@ -45,2 +45,6 @@
- display: block;
+ display: none;
+}
+
+@media (max-width: 768px) {
+ .mobile-menu {
+ display: block;
+ }
+}

This output shows:

  • Commit hash: The unique identifier for this specific commit.
  • Author: Who made the commit, including their email address.
  • Date: When the commit was created.
  • Commit message: The description of what changes were made and why.
  • Diff: The actual changes made to files, following the same format as git diff.

The diff portion follows the same conventions as other Git diff outputs, with lines prefixed by - showing what was removed and lines prefixed by + showing what was added.

© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code