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?
- How to Use “git show” Command With Commit HASH in Git?
- How to Use “git show” Command With Commit HASH and “–oneline” Option in Git?
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:
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:
Then, use the “git show” command to display the commit information where HEAD is pointing:
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:
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:
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:
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.