Review commit history using Git log
Xin (David) Zhao
Computational Biologist | Microbial Epidemiology | Data-Driven Public Health
Git log is a handy command that helps us track commit history.
It provides various arguments and yet they are not equally valuable for practice.
This post demonstrates hot options of the git log command you don't wish to miss.
Show the difference in each commit
$ git log -p -1
'-p' or '--patch' allows us to watch the difference in each commit.
'-1' limits the log entries to the last one. You can choose another integer.
Print a list of modified files for each commit
$ git log -p --stat
Format log output
$ git log --pretty=online
'=online' indicates a given format
Limit log output
Show commits only within a specified time window
$ git log --since=2.weeks
Show commits that only change the specified function
$ git log -S 'function_name'
Show commits that only change the specified file(s)
$ git log --<path to files>