How to colorify git errors, warnings and fatal messages?

When troubleshooting git issues of users, I keep running into people not noticing error/warning messages from git, and then burning their fingers. Is there any way to colorify errors and warnings git outputs?

  • Collaborative programming with Git
  • In Git Bash on Windows 7, Colors display as code when running Cucumber or rspec
  • What is a version control system? How is Git useful?
  • How do I delete a Git branch with TortoiseGit
  • Remove 4 commits from my git history
  • Suggestions on optimizing the EGit on Eclipse
  • Prevent direct commits on master branch in git repository and accept merges only?
  • Make git diff show UTF8 encoded characters properly
  • Why can't I specify another repository for pull request in BitBucket?
  • How to fix git repository broken by interrupted git fetch?
  • A PL/SQL IDE with GIT support
  • How do I Uncommit changes using git
  • 3 Solutions collect form web for “How to colorify git errors, warnings and fatal messages?”

    There is no git buit-in way to do that. Git just prints errors to STDERR and doesn’t care about the fatality of the error or anything. What you can do is color STDERR red. How to do this has been asked on on ServerFault:

    There are three basic options:

    1. Run your command like this:

      *git-command* 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done)
    2. Use a wrapper script (See ServeFault for those), and run commands like

      mywrapper *git-command*
    3. Install stderred. This will allow you to make the effect permanent, without modifying your command line. Not sure whether this will work on windows, though.

    Since I didn’t find a suitable way to color error messages, my solution is to add an additional warning when git returns an error code (!=0).

    To do it, add this to your ~/.bashrc or ~/.bash_profile

    # Wrap git. On errors, print an additional line in red.
        command git "$@"
        local exitCode=$?
        if [ $exitCode -ne 0 ]; then
            printf "\033[0;31mERROR: git exited with code $exitCode\033[0m\n"
            return $exitCode

    Here is the result:
    enter image description here

    Note that coloring stderr in red does not work very well because git logs many things in stderr, not only errors. And some errors are output in standard output.

    You can use the color config section of git.

    For more information and examples see or the second part of

    example: (add to your .gitconfig)

         interactive = always
    [color "interactive"]
         error = red bold
    Git Baby is a git and github fan, let's start git clone.