How grep through your staged files prior to committing?

后端 未结 3 835
灰色年华
灰色年华 2021-02-19 22:05

So prior to running git commit I often will run the following:

git grep --cached -l -I \"debugger\"

I thought it was similar to:

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-19 22:42

    A lot of pre-commit hooks use git diff-index --cached -S 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.

提交回复
热议问题