Colourless Git Output
I teach git and often have issues with bad projectors where you can’t see the colours. Recently I had a setup where even white on black was more or less invisible, but using black text on a white background worked okay. There’s lots of documentation on how to turn on colours in git but not so much about how to turn them off.
Try putting the following into .git/config
:
[color] branch = false diff = false interactive = false status = false
I had expected to be able to set color.ui
to false but that didn’t seem to make much difference, so I now use the settings above. I thought I’d drop it here in case anyone else is looking for the same thing.
From the man page under “color.ui” (version 1.7.10.4):
“This variable determines the default value for variables such as
color.diff and color.grep that control the use of color per command
family. Its scope will expand as more commands learn configuration
to set a default for the –color option. Set it to always if you
want all output not intended for machine consumption to use color,
to true or auto if you want such output to use color when written
to the terminal, or to false or never if you prefer git commands
not to use color unless enabled explicitly with some other
configuration or the –color option.”
So, setting it to false should do the trick, but maybe you have something that overrides it somewhere?
Yeah I think you are right and there is something strange about my setting, that’s one reason why I shared what I actually had to do when the solution from the docs didn’t work for me. I’ll update if I find out what my strange config is!
For the record, I had the same experience as Lornajane. Thanks for the helpful blog post! I came here via Google after also failing to get “color.ui” to do what it was supposed to do. I had expected setting color.ui to work based on reading the same text in the man page, but it simply doesn’t.
On the other hand, setting each of the four color.* parameters individually does work. I have almost nothing else in my global gitconfig (and the system gitconfig is empty) so I find it unlikely that I’ve inadvertently added a config that shadows this; I rather suspect a bug in git, which may have gone undiscovered (and remains unfixed even today) because turning off color seems to be an uncommon request.
Sadly even this does not cover everything. It switched off the colour in *parts* of my `git add -p` output (the diff line numbers and the prompt line) that color.ui didn’t, but the actual diff lines (with the + and – in front) are still green and red. This is a mess. But anyway, thank you for helping me with these two lines at least!
The reason this irks me is that I cannot read coloured terminal output as well as black on (off-)white, and most coloured output from programs running in a terminal is geared towards black background (which also makes reading harder for me). It also doesn’t help to set a terminal type that is unable to set colours (like e.g. vt220); git is oblivious to anything that doesn’t confirm to its world view (which is rather narrow in this respect). Hmpf.