As part of home task part 2, we were asked to read about git log command. So this blog post is dedicated to that. To get more info about git log command I had gone through Git pro book available at https://git-scm.com/book/en/v2/. From this book I had followed chapter https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History to study more about git log command.

When git log is used without any argument, it displays all previous commits in reverse chronological order.

1
$ git log

We can provide following arguments with git log command to see different outputs formats.

  • When -n is passed as an argument, where n is number it would show n number of commits.
1
$ git log -5
  • When -p or --patch is passed as an argument, it shows difference or patch output between each commit
1
$ git log -p -5
  • --stat is used get abbreviated stats of each commits
1
2
$ git log --stat
$ git log --stat -2
  • --since=<date> is used get logs from a particular time. One can pass months, years, days, hours etc to get log from that particular time.
1
2
3
4
$ git log --since="2 hours"
$ git log --since="3 day"
$ git log --since="10 weeks"
$ git log --since="1 year"
  • --author=<pattern> is used get logs from one or many authors.
1
$ git log --author="Bhavesh"

Bonus Video: Thanks for reading the post check out this video on youtube explaining how git works internally.