DEV Community

Cover image for Git Show Command Cheat Sheet
Vishnu Chilamakuru
Vishnu Chilamakuru

Posted on • Originally published at vishnuch.tech

Git Show Command Cheat Sheet

A Beginner's Guide for the 'git show' command

Git is a powerful version control system that allows developers to track and manage changes to their code. One of the most useful Git commands is git show, which allows you to view the details of a specific commit. In this post, we'll explore the git show command and provide a cheat sheet of some of the most commonly used options.

1. Basic Usage

The basic usage of the git show command is to display the details of a specific commit. You can use the following syntax to view the details of a commit:

git show <commit-hash>
Enter fullscreen mode Exit fullscreen mode

This command will display the commit message, the author, the date, and the changes made in the commit.

2. Showing Changes

One of the most useful options of the git show command is the ability to view the changes made in a specific commit. You can use the following syntax to view the changes made in a commit:

git show <commit-hash> --stat
Enter fullscreen mode Exit fullscreen mode

This command will display a summary of the changes made in the commit, including the number of files changed and the number of lines added or removed.

3. Showing Diffs

Another useful option of the git show command is the ability to view the actual diffs (differences) made in a specific commit. You can use the following syntax to view the diffs made in a commit:

git show <commit-hash> --patch
Enter fullscreen mode Exit fullscreen mode

This command will display the actual diffs made in the commit, including the lines added and removed.

4. Showing File Changes

You can also use the git show command to view the changes made to a specific file in a specific commit. You can use the following syntax to view the changes made to a file:

git show <commit-hash> <file-path>
Enter fullscreen mode Exit fullscreen mode

This command will display the changes made to the specified file in the specified commit.

5. Showing Branch

you can also use git show command to see the latest commit on a branch, you can use the following syntax

git show <branch-name>
Enter fullscreen mode Exit fullscreen mode

Conclusion:

The git show command is a powerful Git command that allows you to view the details of a specific commit. It's a useful tool for understanding the changes made to your code and for debugging. The basic usage, showing changes, showing diffs, showing file changes, and showing branch are some of the most commonly used options of the git show command. By mastering these options, you can quickly and easily view the details of specific commits in your Git repository.

Top comments (0)