Coloring your Git output

Do you sometimes have a hard time viewing the output of a Git command? Updating the colors might help! In Git, you can edit the config to change the color of the output. You can set colors per repository or globally. We’ll focus on the global config here. The global config can be edited either by using the git config --global command, or by editing your global .gitconfig file.

Starting with Git 1.8.4, you can set color.ui auto which will color the output with the default colors. You’re also able to set the colors manually if you’re so inclined. You are able to edit the colors of the status, diff, and branch commands.

There are 9 colors available:

If you choose to use the git config --global command, you edit the color.{command}.{property} property. For instance, to change the color of the untracked files listed in the status command to yellow:

git config --global color.status.untracked yellow

If you choose to edit the global file manually, the .gitconfig file can be found at these locations:

OS Path
Windows (Vista up) C:/Users/{username}/.gitconfig
Mac $HOME/.gitconfig
Linux ~/.gitconfig
When editing the file, add a new [color] section for the command you want to edit followed by a list of the properties and colors.

[color "diff"]
    meta = yellow
    frag = magenta
    old = red
    new = green

[color "status"]
    added = yellow
    changed = green
    untracked = red

[color "branch"]
    current = green
    local = white
    remote = red