How to get colored output with git+mintty+mingw on windows?
Asked Answered
E

2

10

I have installed the official windows git distribution, and I installed a recent mingw, and into that the mintty terminal. Then I have copied my git installation to this mingw installation, and now it works from within mintty. My only problem is that the git output is not colored. I suspect that this is because the windows git port tries to use the windows console color thingie and not the ANSI color codes which mintty would be able to interpret. Is it possible to make git use the ANSI color codes instead?

(I have tried a cygwin setup prior to this, but the performance was very, very bad, and I could not find any solution to that).

Embarkment answered 26/2, 2013 at 14:33 Comment(1)
From my experience Cygwin and Mingw are about equally bad in terms of performance. In particular, having a clean PATH variable helps a lot.Mayfield
P
9

from 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.

It looks like git isn't treat mintty as terminal. For me using always instead of true/auto helps:

[color]
  status = always

Forcing color by adding --color flag to diff command work as well (with diff=true):

git diff --color 
Pogey answered 10/4, 2013 at 7:29 Comment(2)
Indeed, it seems that putting always solves the issue. I had a working color setup with the shell shipped with msysgit (which is a standard Windows shell running sh.exe --login -i). Putting always instead of true in my ~/.gitconfig file fix the no color problem with mintty. Thank youPensive
This doesn't completely work, for example git branch. I also had to set branch, diff, and interactive to 'always' in addition to status.Spearhead
A
1

It's simple. Config git to always show color in any ui.

git config --global color.ui always

Works for me.

Agony answered 10/3, 2014 at 21:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.