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.
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
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.
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
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.uiis the default for all commands; a specificcolor.difforcolor.statusvalue overrides it for that command.- Do not use
alwaysglobally. It writes escape codes into files and pipes, which breaks scripts and patches. Use--colorfor a single command, orgit -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. SettingNO_COLORis honored by recent versions for theautomode. git diff --color-moved(ordiff.colorMoved) uses theoldMovedandnewMovedslots to show relocated code in different colors.- Pagers:
lessneeds-R(orLESS=FRX) to show the colors Git sends; seecore.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
#rrggbbonly when you know the terminal supports 24-bit color. - Custom log colors are available in format strings:
%C(red),%C(auto)and%Creset.
Related
core.pager,diff.*,status.*,git diff- Lessons: Setup and config, Log and show