Monday, April 9, 2012

Git Submodule Grepping

git grep doesn't work well when submodules are involved. Some specialized workflows and situations require superprojects though, and git grep is a heck of a lot faster than actually opening and reading all the files with grep. Problem: doesn't work across submodules. Solution: alias.


[alias]
  sgrep = "!f() { git grep \"$1\"; git submodule foreach \"git grep '$1'; true\" | grep -B 1 \"$1\"; }; f"