Find last commit in Git repo that contains a certain string pattern

awk, git, grep

Solution

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

git log -S 'ThisClass(object):'

Problem

I want to go back in time to the last commit which contained code such as, "ThisClass(object):". That code was subsequently removed from the project in a later commit. I thought about using git bisect + grep/awk-ing. I've also heard that git grep may allow you to do this sort of thing, though I can't figure out the right command in the man pages. Any thoughts?

Original source

Related problems