我已经安装了官方的 windows git 发行版,我安装了一个最近的 mingw,并进入了 mintty 终端。然后我将我的 git 安装复制到这个 mingw 安装,现在它可以在 mintty 中运行。我唯一的问题是 git 输出没有颜色。我怀疑这是因为 windows git 端口试图使用 windows 控制台颜色 thingie 而不是 mintty 能够解释的 ANSI 颜色代码。是否可以让 git 改用 ANSI 颜色代码?
(在此之前我已经尝试过 cygwin 设置,但是性能非常非常差,而且我找不到任何解决方案)。
最佳答案
来自 git-config :
If this is set to always, git-diff(1), git-log(1), and git-show(1) will use color for all patches. If it is set to true or auto, those commands will only use color when output is to the terminal. Defaults to false.
看起来 git 没有把 mintty 当作终端。对我来说,使用 always 而不是 true/auto 有帮助:
[color]
status = always
通过向 diff 命令添加 --color 标志来强制使用颜色(使用 diff=true):
git diff --color
关于windows - 如何在 Windows 上使用 git+mintty+mingw 获得彩色输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15091709/