git will color it's output. Staged changes are green and deleted files are red for example. I have a script running several git commands in parallel and I use sponge to get a nicer output.

But using sponge removes the colors, is there a way to change that?


Yes, you can force git to output colour codes. For many git subcommands, you can add the --color option:

git log --color | sponge

For others, you’ll need to configure the colour output using configuration directives; either per command:

git -c color.status=always status | sponge

or for good in one of the configuration files:

git config --global color.status always
git status | sponge

(By default, git disables colour output when its output is sent somewhere other than a terminal. If you want to set the color directive for --color compatible subcommands, you need to use the color.ui key: git config --global color.ui always.)

  • That doesn't work for git status – rinu Oct 4 '17 at 6:50
  • I’ve updated my answer; I didn’t realise you were looking for status (although the green and red references should have given me the hint). – Stephen Kitt Oct 4 '17 at 7:03

Now that I knew what to look for, I found the answer on Stack Overflow:

git -c color.ui=always -c color.status=always status | sponge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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