No Color for Git

Tuesday, October 21st, 2008 @ 10:52 pm | Git

While working with Git recently and git-submodules. I found myself getting an odd error:

error: pathspec '2eed4e6a42d0a50bb6587930659f943f9fae6c44' did not match any file(s) known to git.
Unable to checkout '2eed4e6a42d0a50bb6587930659f943f9fae6c44' in submodule path 'vendor/extensions/file_system'

This normally means you’ve changed a submodule and not properly handled updating it.

In this case though the repository would check out correctly on other users machines just fine. Odd thing was we were all using the same OS (MacOS X 10.5), the save version of git (1.6.0.1) from the same source (MacPorts), and most of the same external libraries installed via MacPorts. There was no real discernible difference we could find between machines.

After beating our heads enough times and enough fiddling around with my .profile, we found the cause. In my .profile I had the following lines:

GREP_OPTIONS="--color=always"
export GREP_OPTIONS
export GREP_COLOR='1;34;43'

These lines give me colored grep output which I personally find more useful than the non-colored variant. Problem is git uses grep for all sorts of functionality, and the colored output was throwing it off. The solution was to remove (or comment out) those lines from my .profile.

My problem here is just that if you simply run grep with the option “--color=never” the colored output would be disabled, resulting in no problems at all. That being said this clearly seems like a bug in git that will hopefully be fixed soon so I can go back to my colored grep output.

Tags: , , ,

One Response to “No Color for Git”

  1. Anonymous Says:

    You really don’t want to use GREP_OPTIONS=”–color=always”. Use GREP_OPTIONS=”–color=auto” instead, and grep will only colorize output sent to a terminal.

Leave a Reply