If the commit is accessible from some ref, the best solution would certainly be to pickaxe: git log -Sstring --all .
If it is not reached, you are right, you will have to do digging. If you think you have ragged commits scattered all over the place, the easiest way is to use git fsck --lost-found to find your ragged commits. (It will also print ragged drops.) Then you can use git grep <commit> for each of these SHA1s and find your line.
On the other hand, if you think that you have several branches of candidates that have been truncated and your goal will be on one of them, I would use git reflog show to look back at your logs, find the commits that were at the ends them and recreate them so you can do git log -Sstring <branches> ^master .
source share