08.21.2019

How to colorize git output

Sometime git status or git diff only show single color, it makes us difficult to recognize changed

In order to make git become colorful, we have 2 ways

Section configuration

vim .git/config

Create new section [color] and add like below

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true

You can also make it in detail like this

[color "status"]
  added = green
  changed = red bold
  untracked = magenta bold

[color "branch"]
  remote = yellow

Or something like this

git -c color.ui=always status
git -c color.ui=always diff

Global configuration

This will apply to all project on your server

git config --global color.ui always
git config --global color.branch always
git config --global color.diff always
git config --global color.interactive always
git config --global color.status always
git config --global color.grep always
git config --global color.pager true
git config --global color.decorate always
git config --global color.showbranch always

Happy coding.

 

Leave a comment