彩色输出:git config --global color.branch auto git config --global color.diff auto git config --global color.interactive auto git config --global color.status auto
7
在 ~/.gitconfig 文件中,只需添加以下内容:
[color]
ui = auto
它会处理所有git命令 .
6
使用Git 2.18,您可以更好地控制在控制台中指定颜色的方式 . The "git config" command uses separate options 例如“ --int ", " --bool ”等 to specify what type the caller wants the value to be interpreted as .
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
6
由_5195224_ @VonC, color.ui 默认为 auto ,因为git 1.8.4 . 不是太快释放;)
9 回答
例如,见http://www.arthurkoziel.com/2008/05/02/git-configuration/
有趣的是
在
~/.gitconfig
文件中,只需添加以下内容:它会处理所有git命令 .
使用Git 2.18,您可以更好地控制在控制台中指定颜色的方式 .
The "git config" command uses separate options 例如“
--int
", "--bool
”等 to specify what type the caller wants the value to be interpreted as .引入了一个新的“
--type=<typename>
”选项,这将使定义新类型更加清晰 .见commit fb0dc3b(2018年4月18日)和commit 0a8950b(2018年4月9日)Taylor Blau (ttaylorr) .
(由Junio C Hamano合并 - gitster - 在提交e3e042b,2018年5月8日)
所以在你有
--bool
和--int
之前,现在(documentation):另一种方法是编辑
.gitconfig
(如果不存在则创建一个),例如:然后添加:
如果你要求,Git会自动为其大部分输出着色 . 你可以非常具体地了解你想要的颜色和方式;但要打开所有默认终端着色,请将color.ui设置为true:
GIT默认使用彩色输出,但在像CentOS这样的系统上它没有启用 . 您可以像这样启用它
您可以从此处选择所需的命令 .
这里 --global 是可选的,可以为系统中的每个存储库应用操作 . 如果您只想为当前存储库应用着色,那么您可以执行以下操作 -
在Ubuntu或任何其他平台(是的,Windows也是!);从git1.8.4开始,这是released 2013-08-23, you won't have to do anything :
所以你会默认看到颜色 .
添加到.gitconfig文件的下一个代码:
由_5195224_ @VonC,
color.ui
默认为auto
,因为git 1.8.4 . 不是太快释放;)从Unix和Linux Stackexchange问题How to colorize output of git?和answer by @Evgeny:
所以基本上它比分别设置不同的
color.*
设置更容易,更具未来性 .从中深入解释git config documentation: