How to colorize output of git?
You can create a section [color]
in your ~/.gitconfig
with e.g. the following content
[color]
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true
You can also fine control what you want to have coloured in what way, e.g.
[color "status"]
added = green
changed = red bold
untracked = magenta bold
[color "branch"]
remote = yellow
I hope this gets you started. And of course, you need a terminal which supports colour.
You probably want to use
git config --global color.ui auto
The auto
part says that git will only try and use color on terminals that support it, and you will not get ANSI sequences if you redirect output of git commands to a file for example. Setting it to true
is same as auto
, and this is also the default since Git 1.8.4.
The color.ui
is a meta configuration that includes all the various color.*
configurations available with git commands.
This is explained in-depth in git help config
.
git config --global color.ui auto
git config --global color.branch auto
git config --global color.status auto