Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've setup grep colors in my ~/.bashrc :

export GREP_COLORS='ms=01;34:mc=01;34:sl=:cx=:fn=35:ln=32:bn=32:se=36'

They work for

  • grep --color=auto
  • grep --color=always

Unfortunately, those custom colors are ignored by:

  • git grep --color=auto
  • git grep --color=always

How to make git grep to use above $GREP_COLORS colors ?

share|improve this question
Git doesn't call the external grep utility, it has its own internal command which is called git grep and has similar but not identical options. – Gilles Feb 2 '12 at 1:16

You should explicitly configure colors in git's configuration file.

Interesting information are found in git-config man page, in particular look for the configuration variable color.grep.<slot>

share|improve this answer

Git grep is not using the GREP_COLORS environment variable. Instead you should add custom entries in you ~/.gitconfig

For example:

[color "grep"]
    linenumber = yellow bold
    match = red
    filename = magenta     
share|improve this answer
How do you do background? – letitbee Aug 17 '15 at 9:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.