Git – git-show Command Line Utility
Last Updated :
22 Feb, 2022
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific application and can modify changes to it that may be seen by other developers. Initially designed and developed by Linus Torvalds for Linux kernel development in 2005.
git show
We use Git in our daily coding activities, however, there are many concepts of Git that are still unknown to people. One such command is git show. Before getting started with what git show is, let us initialize our local directory with git init command and make it a git repository is as depicted below:

When working with Git, we see the .git folder which contains many subdirectories inside it, one such subdirectory is .git/objects directory which contains the information about different types of objects such as blob , trees , commits, and tags.
Blob Object - stores the contents of the file
Tree Object - contains a list of all files in our repository with a pointer to
the blob object assigned to them
Commit Object - points a pointer to its tree object
Tag Object - show the tag message and other objects
included in the tag(object name, object type, tag name)
To view expanded details on these objects we use the command git show. Let us understand more about the command with the help of an example.
We have created a file named demo.txt, wrote 2 lines in it, and committed the changes.

Let’s now use git show command and see what all information we get using the command.
git show <commit id>

We can see that there is a lot of information that we got when we use git show command. From the above image, we can infer that git show command shows us 2 things
- Part 1: The commit message and the pointer to which the HEAD is pointing.
- Part 2: Second thing that can see is the different versions of the file .
Let’s discuss the 2 parts to some depth as follows:
PART 1


The first part gives us the same result as when we type the git log command which tells us about the commit history of the commit id.
HEAD -> master
Tells us about the pointer where the HEAD is currently pointing.
Since this commit had a pointer to the HEAD, let’s see another example of git show where the commit doesn’t have a pointer to the HEAD.

We didn’t get HEAD->master here as this commit is not pointing to the HEAD.
PART-2

As we can see that this part starts with diff –git a/demo.txt b/demo.txt .
- diff here means the difference, difference in between the file that is pointing to HEAD.
- a/demo.txt and b/demo.txt show the 2 versions of the file demo.txt.
git diff command in git is used to track the difference between the changes made on a file. It shows the changes between the commits, working tree, branches, files .
One can try and check git show command by trying it on various commit ids.
Similar Reads
Git - git-show Command Line Utility
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git relies on the basis of distributed development of software where more than one developer may have access to the source code of a specific ap
3 min read
How to Install Git on Windows Command Line?
Git is an open-source and free, decentralized version control system designed to handle projects of all sizes with speed and efficiency. Basically, it is a software tracking application that is commonly used to monitor projects across several teams. The best way of downloading and installing Git on
3 min read
How to Dry Run Git Commands?
Git is used for version control in software development. Understanding the effects of Git commands before executing them can help prevent mistakes and ensure that your repository remains in a good state. This is where "dry running" Git commands become incredibly useful. A dry run simulates the execu
3 min read
Using Git on CommandLine
Git is very important and powerful tool when it comes to the software development life cycle. Now in this article, we are going to see why git is used vastly in the software industry and what kinds of operations we can perform with git. So git is basically a distributed version control system for tr
5 min read
How To Get The Git Commit Count?
Tracking the number of commits in your Git repository can provide insights into the development progress, team activity, and overall project health. Whether you want to get the total commit count or see the number of commits by each contributor, Git offers several ways to retrieve this information.
2 min read
How to Squash Commits in Git?
Maintaining a clean and organized Git history is very important for collaboration and project management. One way to streamline your commit history is by squashing commits, which combines multiple commits into a single, more coherent commit. In this article, we will see how to squash commits in Git.
2 min read
What is Git Commit?
Git is a powerful version control system that helps developers manage and track changes in their code. One of the fundamental concepts in Git is the "git commit." This command is important for recording changes to a repository and forms the backbone of version control. In this article, we will explo
5 min read
How to Back Commit in Git?
In this article, we are covering how to undo commits in Git. Sometimes, you might make mistakes or realize you need to revert changes you made in a previous commit. Luckily, Git offers a few ways to undo commits. Table of Content Approach 1: Using 'git revert'Approach 2: Using 'git reset' Approach 1
4 min read
How to Use Git Shell Commands?
Git is a powerful version control system that is important for managing source code in modern software development. While there are many graphical user interfaces (GUIs) available for Git, mastering Git shell commands can significantly enhance your productivity and control over your repositories. Th
3 min read
How to Revert a Git Commit?
In software development, mistakes happen, and there will be times when you need to undo changes in your Git repository. Reverting a Git commit is a common task that can be handled in several ways, depending on your needs and the state of your project. This article will guide you through the differen
4 min read