Skip to content
Tutorials Center
My learning

Topics

Git Reference ยท Configuration Options

The color.* settings

Reference for Git's color.* settings: turn colors on or off with color.ui, tune diff, status and branch colors, and write color specs like 'bold red'.

Git colors its output with ANSI escape sequences: green and red in diffs, yellow commit hashes in logs, colored branch names. The color.* family controls whether that happens and which colors are used. The master switch is color.ui; commands such as diff, status, branch, grep, log and interactive also have their own color.<command> switch and color.<command>.<slot> color settings.

With the default color.ui=auto, Git colors only when output goes to a terminal, so pipes and redirections receive plain text.

Terminal
git config --global color.ui auto
git config --global color.diff.new "green bold"
git config --global color.status.changed "yellow"
git -c color.ui=always diff | less -R

Try it

Bash Seeing the escape codes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Bash Custom colors for one slot

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
git config color.ui <auto | always | never | true | false>
git config color.<command> <auto | always | never | true | false>
git config color.<command>.<slot> "<foreground> [<background>] [<attribute>...]"
Setting Slots (examples)
color.diff.<slot> meta, frag, func, old, new, context, commit, whitespace, oldMoved, newMoved
color.status.<slot> header, added, updated, changed, untracked, branch, nobranch, unmerged
color.branch.<slot> current, local, remote, upstream, plain
color.grep.<slot> match, filename, lineNumber, separator
color.decorate.<slot> branch, remoteBranch, tag, stash, HEAD

Color specs: names normal, black, red, green, yellow, blue, magenta, cyan, white and their bright variants; a number 0-255; or #rrggbb. The first color is the foreground, a second is the background. Attributes: bold, dim, ul, blink, reverse, italic, strike, each negatable with no- or no.

Values: auto (or true) colors only for terminals, always colors even when piped, never (or false) disables colors.

Usage notes

  • color.ui is the default for all commands; a specific color.diff or color.status value overrides it for that command.
  • Do not use always globally. It writes escape codes into files and pipes, which breaks scripts and patches. Use --color for a single command, or git -c color.ui=always.
  • Windows and NO_COLOR: terminals that do not understand ANSI codes show stray characters; Git for Windows enables the console mode for you. Setting NO_COLOR is honored by recent versions for the auto mode.
  • git diff --color-moved (or diff.colorMoved) uses the oldMoved and newMoved slots to show relocated code in different colors.
  • Pagers: less needs -R (or LESS=FRX) to show the colors Git sends; see core.pager.
  • Reset sequences: each colored span ends with a reset (ESC[m), so you can safely concatenate output.
  • Terminal themes change what "red" looks like; use #rrggbb only when you know the terminal supports 24-bit color.
  • Custom log colors are available in format strings: %C(red), %C(auto) and %Creset.