'git grep' and word boundaries on Mac OS X and BSD
After dealing with this, I also found this very useful post on the BSD mailing list. So here is a (albeit rather ugly) solution:
git grep "[[:<:]]blah[[:>:]]" The -w git -grep flag also works, but sometimes you want to combine only the beginning or end of a word.
Update: This has changed in OS X 10.9 "Mavericks". Now you can use \< , \> and \b . [[:<:]] and [[:>:]] no longer supported.
You can compile git with PCRE support and use git grep -P "\bblah\b" for word boundaries.
Here is a guide to compiling git using OSX Homebrew: http://realultimateprogramming.blogspot.com/2012/01/how-to-enable-git-grep-p-on-os-x-using.html