Products Resources Support About Us

Rocket Software

Colors are not interpreted correctly when using git diff

Has anyone had this issue where git diff does not show colors correctly? Clearly it’s trying to display the escape sequences but they aren’t coming out right. It works fine for git branch -v so just wondering if there is something I’m doing wrong.

Actually, git log also does not interpret colors correctly so there is a general issue with escape sequences that works for the git branch -v but not other commands.

/u/devcgc/repos/zeke_test []$ git log
33mcommit 3aae8ee22a8b11e3f6d5de59a0a79ae47b9f62aam
Author: Clay Crowell <>
Date:   Fri Apr 21 12:07:18 2017 -0400

    zteam-999: ptf z620tac - change to zekeca4 in zeke01a

33mcommit d047d268220a8eeb2f8d1466ee6dfbdba6c86b6bm
Author: Clay Crowell <>
Date:   Fri Apr 21 11:37:11 2017 -0400

    ZTEAM-999: ptf z620taa - change to the zekeca3 are of zeke01a

I found the issue. One of our developers recently installed “less” on our system. That caused the colors to not work.

I found another forum that mentioned setting core.pager. That sort of worked although it caused a new issue, essentially removing “less” from the picture. Any ideas how to set core.pager so I don’t have the issue you see below and still get my colors?

Hi Clay,

Notice, GIT_SHELL has to specify executable file:
export GIT_SHELL=/some/path/bash-4.3_b017.170426/bin/bash
instead of
export GIT_SHELL=/some/path/bash-4.3_b017.170426/bin

Also if you use additional bash scripts for git (not from Rocket’s archive), you should replace numeric values in escape sequences. E.g.:

  • replace \x1b, \x1B or \033 with \e
  • \x0A with \n
  • \x0D with \r

This works for me. Does your user have permissions to execute less?

I was able to get colors in the diff output by changing the pager to “pg”.

git config core.pager 'pg'

1 Like

Another way to break git color support in the default set up, is to set the LESS environment variable. I was bit by this when I set LESS=-i to have default case insenitive search. Then I didn’t use the notebook for a week . Then I used git diff and it was “broken” I had forgotten that I set LESS, so spent a lot of time figuring out that setting LESS had broken the git default pager (less).

Fairly well docummented here:

I added this to my .gitconfig; you may also want to add X there:

  pager = less -FR