Git

Git Show Command in Git | Explained

Git is the freely available and distributed version control system that is utilized for handling development projects efficiently. Source code files are created in the working area and then saved into the Git repository by committing and users can access, view, and modify these files whenever they need.

This blog will talk about:

What is the “git show” Command in Git?

The “git show” command is utilized for viewing the expanded details on Git objects, such as trees, and commits. In simple words, it is the particular behavior per object type.

Syntax

The general syntax of the “git show” command is provided below:

git show <options>

Here, adding “options” is optional.

How to Use “git show” Command in Git?

The “git show” command is used for viewing the most recent commit’s detailed history.

Firstly, move the Git root directory, and execute the “cd” command with the directory path:

cd "C:\Users\nazma\Git"

Then, use the “git show” command to display the commit information where HEAD is pointing:

git show

As you can see, the most recent commit detail has been shown that contains the commit SHA hash, author email address, committing date, time, commit message, and available file data:

How to Use “git show” Command With Commit HASH in Git?

We can also use the “git show” command with the particular commit SHA hash for displaying their detailed information. To do so, view the Git log history in one line by running the “git log” along with the “–oneline” option:

git log --oneline

From the given output, we have selected the “b175986” commit SHA hash for further processing:

Run the “git show” command with the previously selected commit id:

git show b175986

As you can see, detailed information about the specified SHA hash has been displayed:

How to Use “git show” Command With Commit HASH and “–oneline” Option in Git?

The “git show” command can be used with the “–oneline” option for displaying the desired output with a single line as follows:

git show b175986 --oneline

Here, the commit edit details have been displayed with a single line instead of author information:

That’s it! We have compiled detailed information about the “git show” command in Git.

Conclusion

The “git show” command is utilized for displaying the expanded details on Git objects, such as trees, and commits. It can be executed with and without options. This blog briefly discussed the usage of the “git show” command in Git.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.