Git search for string in a single file's history

git

Solution

For this purpose you can use the -S option to git log:

git log -S'bar' -- foo.rb

Problem

So if I have a file called foo.rb and it is giving me an error for a missing method called bar, so I want to search the history of foo.rb for the string `bar` to see if it was ever defined in the past. I found this Search all of Git history for a string? But this searches all files. I just want to search in one file.

Original source

Related problems