Git log
offers useful options for filtering. This card provides a short overview.
Only commits that include a specific string in their commit message
git log --grep="tracker id"
Only commits that introduced changes to a specific file
git log -- foo.rb bar.rb
If you want to know when a specific line of code was added in the project
git log -S"def function_name"
If you want to know which commits have been added between two commits.
git log base_branch..compare_branch
will show you how many commits were added to compare_branch
since base_branch
.
git log -n
to show only the last n
commits.
git log --since 2023-02-17
to show only commits from that date until today.git log --until 2021-01-19
Note
The
--since
and--until
flags are synonymous with--after
and--before
, respectively.
git log --after="2014-7-1" --before="2014-7-4"
You can use references like "2 years 1 day 3 minutes ago" and "yesterday": git log --after="yesterday"