Git search for string in a single file's history
For this purpose you can use the -S option to git log:
git log -S'bar' -- foo.rb
Or maybe you can try this one (from related questions Search all of git history for string)
git rev-list --all foo.rb | (
while read revision; do
git grep -F 'bar' $revision foo.rb
done
)
It will actually look for file content and not commit messages/patches for any occurence of bar.
There's an override for git log command (from manual):
$ git log Makefile # commits that modify Makefile
So you could use:
git log foo.rb | grep "bar"