So viewing the list of commits is great. But what if we want to
see what exactly we have changed in a given commit, that's when
we use the show command. For example, let's say we want to
look at the content of this commit over here, we type Git
show. Now here, we need to specify the commit, we want to
inspect, there are two ways to reference a commit, we can
reference it using its unique identifier. So we type d, 601,
B, 9 0. Now we don't have to type all the seven characters,
we can type fewer characters, as long as we don't have another
commit, whose ID starts with these characters. So that's one
way to reference a commit. And another way is to use the head
pointer. So look, head is currently in front of the last
commit. So to view the last commit, we can type head or to
look at previous commit, we can type a till there, and then
specify how many steps we want to go back. So if we type one,
we start from head which is here, we go one step back, and
this References This comment over here. Let's take a look. So
on the top, we can see the author and the date of this
commit, as well as its message. Below that we have a diff of
what has changed. So in this commit, we have changed a single
file that is git ignore. Over here, we can see that we removed
this line and added these two lines. So this is very useful.
Now what if we don't want to see the differences, we want to see
the final version, the exact version that is stored in this
commit? Well, you bring up the last command, get show head till
the one. Then we type a colon. And here we specified the full
path to a file. For example, we can say, dot Git ignore or if
this file is in a subdirectory. We type for example, bin slash
app dot bin Okay, now let's look at Git ignore. So this is the
exact version stored in this commit. Now, earlier I told you
that each commit contains a complete snapshot of our working
directory, not just changes, but when we run the show command. We
only see the differences? What is changed? What if you want to
see all the files and directories in a commit? Well,
for that, we're gonna use a different command. That's called
LS tree. Now why is this called a tree, well, it tree is a data
structure for representing hierarchical information. So in
a tree, we can have nodes, and these nodes can have children.
Now directory on the file system can be represented using a tree.
Because each directory can have children, these children can be
files, and other sub directories. If you want to
learn more about this concept, you should take my dat
structures course. So LS tree m ans list all the files in a t
ee. Now here we specified the c mments we're interested in had t
lde one. And now look, these a e all the files and d
rectories stored in this c mmit. So we have Git ignore. R
ght before that we have a u ique identifier that is g
nerated based on the content o this file. So in gits d
tabase. We have an object with t is ID. Below that we have b
en, again, it has a unique i entifier that is generated b
sed on the content of this d rectory, now look at the type o
this object, it's a tree. So f les are represented using b
obs, and directories are r presented using trees. All of t
ese are objects that are s ored in gits database. Using t
e show command, we can easily v ew an object and gits d
tabase. For example, if we t pe Git show, and then specify t
is unique identifier, or we c n type only the few c
aracters, as long as there is n ambiguity. So here's the c
ntent of our Git ignore file. A another example, let's look a
this object, this tree, the b n directory, so git show 6
629. Here we have a tree. In t is tree, we have this file, a
p dot bin. So using the show co mand, we can view an object an
gets database. These objects ca be commits, blobs, which re
resent files, and trees which re resent directories, as well as
tags. We'll talk about tags in the future.