Last Updated on January 30, 2021 by sandeeppote

Git log shows commit logs. Helps to see the paginated view of the commits made to the repository. To see commit logs-

git log

This shall give you the list of commits having specific information.
Commit ID, Author, Date of Commit and Message

This is how we see what changes has been in the past done on the project.


If you try to see log in a non commit repository i.e. if not a even single has been mage to repository it shall give fatal error-

fatal: your current branch ‘master’ does not have any commits yet

If you want to see the logs in one line-

 git log --online


Here you can see the difference the log is displayed with short SHA value and comments.

If you wish to see limited number of logs or see recent number of commits use following-

 git log -n 5

This shows recent 5 commits made to repository. You may also use this-

 git log -5

If you want to see the time period since the commits were made-

git log --since="2018-01-01"

If you want to see the time period until certain date the commits were made-

git log --until="2018-01-01"

There is lot of flexibility for using time period-

git log --since="3 weeks ago" --until="4 days ago"

To search by author-

git log --author="authorname"

To do a global search use-

git log --grep="commit"

grep means global regular expressions and will search in commits for specified search value.

If you want to see the from a particular commit for a particular file-

git log SHA123.. file.txt

SHA123 is a commit ID and .. if after that for file.txt

git log --stat --summary

Will give the what has been changed and quantity of change.

By default the commits are shown in chronological order, if you want to change the order of the commits-

 git log --date-order

This shall show the commits in date and time descending order

There are more options on this, you may see here to know more.

To view whats in the commits use-

git show SHA-VLAUE

This shall show the changes that happened in the commit for mentioned commit ID with the differences in the file content.
git show can show the commits based on SHA, blob or tree.