Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In the last movie, we saw how to get more out of the commit log, so any time we're looking at the commit log, we're looking at a list of commits. What if we want to look at a specific commit though? We want to see what changed. What was this commit all about? I want to examine it and see what was committed. Well we do that with git show, so git show followed by a SHA, so let's take a look here at git log --oneline, and get a list of our commits, and then let's show one of them, git show, and let's take a look at this one here, moved sunglasses higher in list of suggested outdoor items.
So I just paste the SHA right there and then hit Return. It shows me the full SHA for the commit, it shows me the author of the date, the commit message and then gives me a diff of the commit. Remember we saw diffs before when we were trying to see what had changed before we decided what content we wanted to commit. We could diff the two to see what changed. Well, here it's showing us what was committed, the diff between what was there before and what was there after. So sunglasses was added in this spot, and it was removed in this spot. That's what the change was, and it gives me the plus and the minus as well as some coloring to indicate the changes.
I can hit space to make sure that there is nothing else after it, and then Q to quit out of it. So that's it, that's what a show looks like. Let's take a look again in our log, let's take a look at different one, let's say this one where we add a file. Let's see what that looks like, git show, and that SHA, and there it is. It's adding a file, so diff is /dev/null which is computer speak for empty, so it didn't exist before, and now here it is. So compared to nothing, it's all added, all these items are added here, all new.
Same thing if we delete something, it'll of course all be removed, it'll show them all as being minuses. Now that you can also pass in formats here, mainly it has to do with what the format looks like at the top, so let's say format=, and we can have oneline and then let's give it our SHA, I'll just say HEAD, so there is what our HEAD looks like. Let's take a look at HEAD back one, there is the one that's before that, and let's do HEAD back two, or HEAD~3, that shows us the commit that was before that, so we can surf around and go back and look at these commits.
There are some other options you can pass in. You can look through the help documents to find those. Now what we're passing into it is a tree-ish object like before, but git show actually does handle them all a little differently. If we do the help docs git help show, you'll see it takes blobs, trees, tags and commits, so we're mostly working with commits here. If we passed in a tree, it would show the names of what was in the tree, it's equivalent to doing git ls-tree with the name-only option, so it's the exact same thing.
For plain blobs, that's files, it shows the contents. Let me just demonstrate both of those real quick. So let's do git ls-tree master, so there is our list. Here is the one for assets, so I'm just going to grab the first part of that and tell it git show that tree. That's the tree that we want to focus on, that's the tree-ish object we're passing in, it comes up and gives me a list of what's inside there. Again this is same as git ls- tree with the name-only option. Let's do the same thing for our file.
We have our index file here, again, we pass in the tree-ish object, git show, and then we pass in that SHA, and there it is, there's the content. Now I just want to point out that that's not the same thing as saying git show index.html. That's not a tree-ish. We can't pass that in. That is not a reference that it understands as a tree-ish object, so it comes up and it says I don't know what that is. We have to pass in the SHA or some other reference to the file that it can understand a tree-ish.
So I think between viewing the tree, viewing a log file, and viewing the commits, you'll be able to navigate around and really see what's been committed to the repository before. The last thing that's super useful is being able to compare commits, and that's what we'll do in the next movie.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 99436 Viewers
56 Video lessons · 112665 Viewers
71 Video lessons · 81493 Viewers
131 Video lessons · 39121 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.