init: git log
In this video we'll learn how to use
So far we've been working with the most recent commit.
There will be times where you will need to see older commits.
For this you can use
To demonstrate I'll run
git log on the repository we created in Part 2.
Don't worry if you haven't been following along. You can run
git log on any repository.
git log, we see information for each commit we've made so far.
By default these commits are in reverse chronological order. So it lists the most recent commit is first and goes all the way back to your initial commit.
The information includes the full commit SHA, author, date, and full commit message.
You can use the arrow keys to scroll through the log. At anytime, you can type q to quit.
git log outputs more than we need either in the number of commits or the detail of information.
We can limit the number of commits to shown with the
-n option or
-# for short.
For example, if we wanted to see the two most recent commits, we can run:
git log -2
We can also limit the information shown by using the
In this case,
git log will only display the short SHA and the title of the commit message.
Finally, we can also pass
git log a file to see its specific commit history.
For example, to see the condense commit history for File 2 we can run:
git log --oneline file-2.txt
git log has many more options with a virtually unlimited number of combinations.
Although we'll learn a few more of them in Master: git log, these are the options you'll use most often.