How to grep the git diff?

后端 未结 9 911
耶瑟儿~
耶瑟儿~ 2021-01-31 06:55

Is there a way to show the git-diff filtered by a given pattern.

Something like

git grepdiff pattern

changed file
+++ some sentence with pattern
change         


        
9条回答
  •  半阙折子戏
    2021-01-31 07:34

    On Windows, a simple solution is:

    git diff -U0 | findstr string
    

    If you want grouping by filename, use this

    FOR /F "usebackq delims==" %i IN (`git diff --name-only`) do git diff -U0 %~fi | findstr string
    

提交回复
热议问题