Find the last commit in a Git repo that contains a specific string pattern

I want to get back to the time of the last commit containing code such as "ThisClass (object):". This code was subsequently removed from the project in a later commit.

I was thinking about using git bisect + grep / awk-ing. I also heard that git grep can allow you to do such things, although I cannot figure out the correct command in the man pages.

Any thoughts?

+5
source share
1 answer

Use the -S (search) argument to git log:

git log -S 'ThisClass(object):'
+11
source

All Articles