Read more

Useful filtering options of git log

Felix Eschey
August 16, 2023Software engineer at makandra GmbH

Git log offers useful options for filtering. This card provides a short overview.

By message

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Only commits that include a specific string in their commit message

git log --grep="tracker id"

By file

Only commits that introduced changes to a specific file

git log -- foo.rb bar.rb

By content

If you want to know when a specific line of code was added in the project

git log -S"def function_name"

By range

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.

By count

git log -n to show only the last n commits.

By date

  • You can also use git log --since 2023-02-17 to show only commits from that date until today.
  • If you want all the dates until a specific date, you can use git log --until 2021-01-19

Note

The --since and --until flags are synonymous with --after and --before, respectively.

  • You can combine both too: 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"

Posted by Felix Eschey to makandra dev (2023-08-16 14:47)