How to use --color-words with git add --patch?

前端 未结 7 1841
梦谈多话
梦谈多话 2020-12-07 17:27

When diffing files, I prefer to use git diff --color-words. Is there a way to make this the default format for diffs when using git add --patch or

7条回答
  •  孤城傲影
    2020-12-07 18:00

    As mentioned earlier adding diff-highlight to the interactive.diffFilter config key is the easiest option (since Git 2.9). The following comand does the trick on Debian/Ubuntu without copying scripts, changing permissions or mangling $PATH:

    git config interactive.diffFilter "perl /usr/share/doc/git/contrib/diff-highlight/diff-highlight"
    

    Things like git -c interactive.diffFilter="git diff --color-words" add -p or git config interactive.diffFilter "git diff --color-words" don't work properly: add -p always keeps suggesting the first modified file.

提交回复
热议问题