我已经使用Git一段时间了,但是直到今天,我才意识到我可以为diff,grep,branch,show-branch和status提供彩色输出,而无需使用任何其他外部工具(例如colordiff)。
这是我的〜/ .gitconfig文件,它启用color :
[user]
name = Nick Boldt
email = nickboldt (at) gmail.com
[giggle]
main-window-maximized = false
main-window-geometry = 1324x838+0+24
main-window-view = HistoryView
[core]
trustctime = false
branch = auto
diff = auto
interactive = auto
status = auto
editor = vim
[merge]
tool = vimdiff
[receive]
denyCurrentBranch = warn
[branch]
autosetuprebase = local
[color]
ui = true
diff = true
grep = true
branch = true
showbranch = true
status = true
[color "diff"]
plain = normal dim
meta = yellow dim
frag = blue bold
old = magenta
new = cyan
whitespace = red reverse
[color "status"]
header = normal dim
added = yellow
untracked = magenta
[color "branch"]
current = yellow reverse
local = yellow
remote = red
翻译自: https://www.javacodegeeks.com/2012/03/git-in-colour.html