git grep--but restricted to new or modified files in the index

It turns out the way to do this is not via git grep, but by a completely different command, that also happens to be able to search: git diff-index. (Another triumph for simplicity and orthogonality...)

What I wanted can be achieved via:

$ git diff-index -U --cached -G <regexp> HEAD

I usually just do something like:

git diff | grep TODO

If you have enough changed lines to make that annoying, then I add | grep '^+', or start messing around with -[ABC] options.

Tags:

Git

Grep