While git log
helps you see the commit messages but by default it does not output what actually changed. Thankfully the command is extremely flexible and the additional options provide useful insights into the history of the repository.
Examples
To see the overview of the commits in a short view use the command git log --oneline
To output the commit information with the differences of what changed you need to include the -p prompt such as git log -p
This will output the entire history. You can filter it with a number of different options. The -n <number> specifies a limit of commits to display from the HEAD. For example git log -p -n 2
displays HEAD and HEAD~1.
If you know the time period then you can use a time period to between commits before a particular date using --since="2 weeks ago" and _--until="1 day ago".
As with most Git commands, we can output a range of commits using HEAD...HEAD~1
as shown in the terminal.
Use the command git log --grep="Initial"
will output all the commits which include the word "Initial" in their commit message. This is useful if you tag commits with bug-tracking numbers.
Protip
As we discussed in the merging scenario, your commit history can become noisy due to use merge notification commits. To remove them provide the argument -m with git log.