在执行了
git config --global interactive.diffFilter diff-highlight
命令后,我的.gitconfig
文件变成了这样:# This is Git's per-user configuration file.
[user]
name = Vitaly Zdanevich
email = vitaly.zdanevich@xxx.com
[core]
excludesfile = /Users/vitaly/.gitignore_global
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge --skip -- %f
process = git-lfs filter-process --skip
required = true
[diff]
tool = vimdiff
context = 20
[difftool]
prompt = false
[interactive]
diffFilter = diff-highlight
在git commit -p
和git add -p
中,我看到了同样的逐行无色差异,默认情况下使用terminal.app
:
我还尝试过:
git -c interactive.diffFilter="git diff --color-words" add -p
结果如下:
fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.
我使用的是官方命令行工具自带的git版本,版本号为2.17.2 (Apple Git-113)
,操作系统为macOS 10.14.1
,而非使用Brew安装的版本。我更喜欢简单易用的方式。
diff-so-fancy
:https://github.com/so-fancy/diff-so-fancy/issues/296。 - WloHu