我最近看到Windows中的git控制台是有颜色的,例如,绿色表示添加,红色表示删除等等。我怎么给git控制台上色呢?

要安装它,我使用命令:$ sudo apt-get install git-core


当前回答

添加到你的.gitconfig文件下一个代码:

[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

其他回答

如果您要求,Git会自动为大部分输出上色。你可以非常具体地说明你想要什么颜色以及如何着色;但是要打开所有默认的终端颜色,请设置颜色。UI为true:

git config --global color.ui true

在你的~/。Gitconfig文件,简单地添加这个:

[color]
  ui = auto

它负责所有的git命令。

例如,参见https://web.archive.org/web/20080506194329/http://www.arthurkoziel.com/2008/05/02/git-configuration/

有趣的是

彩色的输出: Git配置全局颜色。分支汽车 Git配置全局颜色。diff汽车 Git配置——global color.interactive auto Git配置全局颜色。地位的汽车

添加到你的.gitconfig文件下一个代码:

[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

在Ubuntu或任何其他平台(是的,Windows也是!);从2013年8月23日发布的git1.8.4开始,你不需要做任何事情:

许多教程教用户设置“颜色”。将“user.name/email”设置为“auto”后的第一件事,用于向Git介绍自己。现在该变量默认为"auto"。

所以默认情况下你会看到颜色。