With a few commits under our belt, this is a great time to introduce the "git log" command. There will be a time when you want to see the history of your repository and "git log" lets you do that. There are any number of reasons you might want to view the git log. You might want to know when you made a specific code change, or compare your local repo with the central remote repo for example. (We'll talk about using "git log" with remote repositories in a later video.)
Let's take a look at the basics of how it works.
- I'll type "git log" and press Enter
When I do that, we'll see three sections, one for each commit we've made so far. Each section contains the following information:
* Commit hash id
* Author
* Timestamp of when the commit was made
* Commit message
Often, when I need to look through the git log, I don't need (or want) the full commit hash, author, or date, so I add the "--oneline" option, witch does just that.
- I'll type "git log --oneline" and press Enter
This time, we only see a shortened hash, and the commit message. Almost every time I check the git log, this is the command I use because I can perform actions (like revert and reset with this shortened hash, and the commit message is what I need most often. (We'll talk about revert and reset in later videos.)
Now that you have a basic understanding of how Git works locally, I'm going to introduce you to remote repositories, which are essential when working on a team, when you use multiple machines, or just for keeping an off-site backup of your work so that you can pickup where you left off in case something happens to your machine.