How grep through your staged files prior to committing?
A lot of pre-commit hooks use git diff-index --cached -S<pat> REV
to find changes which add or remove a particular pattern. So in your case, git diff-index --cached -Sdebugger HEAD
. You may want to add -u
to get a diff as well, otherwise it just identifies the offending file.
If you have a Unix-like shell available, the answer is pretty simple:
git grep --cached "debugger" $(git diff --cached --name-only)
This will run git grep
on the list of staged files.