Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
Now that we've made our first commit, and we've talked about how to write good commit messages, let's take a look at where those commit messages show up by viewing the commit log. The way that we do that is with git log, very common sense, and this will show us the log of commits that have taken place so far, right now there is only one. If there have been more than one then we would see them listed one after another. Now each one of these commits has some basic parts to it. So here it is, I am going to highlight it, we've got the commit ID, this is the identifier for this commit, we'll talk more about that a little while later.
But each commit has a unique ID, that's what this number is here, it tells the Author of the commit, you can see that it pulled this information from my global configuration. So that's how it knew who was making this commit, that's why that was the very first configuration that we did, it's very important to do when you first set up your Git Repo, put in your information so that it can tell with each commit who is making the commit, and then the date that the commit was made and then the message. Now if we'd had a longer message here then of course, it would have one line followed by a space followed by a multi-line message that was below that.
So this is the way to see what's happened in the past in a project. So, for example, if I am collaborating with team members on a project, and we all are making commits to a single repository, if I want to log on in the morning, and I want to see the changes that they've made, and I want to take a look at what those are, then I use git log to look and see what changes they've committed. Now I can then go in and view detail on any one of these if I want to get a little more information. But the commit log uses those commit messages which hopefully are very descriptive to let me know what has changed about the project.
Now there are a number of options that you can use with log, we'd use git help log. We can bring the manual page up that will show you what a lot of those are. I am going to show you just a couple of them real quick. So if we use git and then log with -n followed by a number it will limit the number of commits that it returns to us. Now I only have one commit, so if I say git -n 1 it returns that single commit, same thing if I say git 2, it returns just this single commit. Let's go ahead and put git 0, which is kind of silly, but that will return no commits. So you can see that it limits the number of commits that get returned to us.
So if we only want to look at the most recent five, we can use this to see just the most recent five. We also have the ability to specify the time periods that commits took place. So git log --since=, and I'll put in a date that is going to be everything since that date, and you see nothing comes up, but if I do it from the day before my last commit, then you see everything since that date does pop up, and that commit shows up. Same thing with until, let's go ahead and just do come back to this one, and I'll edit since to say until, so everything leading up until the 15th of June shows up.
If I change it to the 14th then the commit doesn't show up, because the commit was made on the 15th. So I can use since and until, and I can use them both together, so if we want to just see commits between a certain range. Notice that I have the Author here, I can also say that I only want to see commits by a certain Author. Author= and then in quotes or without quotes, I can put just part of the name that I want to look for. Look for Author that is Kevin, and you'll see that it brings up my commit. But if I had another person in here, let's say it's Joe, then of course it doesn't find anyone with commits named Joe. This kind of searching in the Author field can also be done in the commit message field using grep, that's very handy.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 92409 Viewers
82 Video lessons · 104127 Viewers
71 Video lessons · 75558 Viewers
56 Video lessons · 106939 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.
Your file was successfully uploaded.