我在哪里可以找到 git 的所有颜色选项?

Where can I find all of git's color options?

我想自定义 git 颜色输出。

  1. 在哪里可以找到可以指定颜色的所有选项的列表?

  2. 在哪里可以找到我可以设置选项的所有颜色和修饰符?

例如,我在哪里可以找到完整的选项列表,例如:

color.ui
color.branch.current
color.branch.upstream
color.diff.new
color.diff.newMovedAlternative
color.diff-highlight.oldNormal
color.grep.match
color.interactive.help
color.status.untracked

以及颜色和修饰符的列表,例如:

blue green red
bold dim blink strike no-bold

这一切都由git config控制。

颜色列表可在 color 获得。如此处所述,不同的控制台支持不同的颜色。例如,在 Windows 中,您在 PowerShellcmdmingw64 中看不到完全相同的颜色,后者使用 bash 端口用于 Windows.

有很多颜色可以配置。例如,运行 git status 时使用的颜色是 here。但是还有更多的颜色,例如 diffgrepmergeblame...它们都有默认配置,我建议您除非必要,否则不要更改,这样使用您的 git 环境的任何人,或您使用其他环境的人,都能始终看到标准颜色。

如果您 运行 git config --get-regexp color 您可以看到配置文件中配置的当前颜色,.gitconfig,但是,如上所述,这只是您明确指定的颜色变了。查看不同现有 git 配置文件的帮助:本地、全局、系统(存储库、用户、机器)。