windows - 如何在 Windows 上使用 git+mintty+mingw 获得彩色输出?

标签 windows git mingw mintty

我已经安装了官方的 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/

相关文章:

c++ - 通过 Eclipse CDT IDE 运行 C++ 应用程序时无输出

c - 如何在 Windows 上调试 C 程序?

python - Windows subprocess.Popen 没有 shell=True 的批处理文件

windows - 列出使用智能卡读卡器的进程

git - 如何忽略已提交给 Git 的文件的任何更改

git - 忽略 .gitignore 中除一个目录之外的所有内容

mingw - 使用mingw交叉编译时找不到zlib头文件?

c - 如何调用仅在特定操作系统版本中可用的 C 函数?

windows - Scala 2.9 无法在 Windows XP 上运行 "hello world"示例

GitX - 如何查看单个文件的提交历史记录?