How to change color in git diff

53 views Asked by At

I was able to change color for old, new, and meta regions, but I can't find the option to change the color of @@ -1 +1, 2 @@ (in the picture) and the color of the red square at the end (in the picture).

git diff output

1

There are 1 answers

1
mx0 On BEST ANSWER

Hunk header color option is called color.diff.frag.

Whitespace at the end is called color.diff.whitespace.
Whitespace uses background color so you have to set both colors (thanks @IGRACH)

You can test it like this:

git -c color.diff.frag=yellow -c color.diff.whitespace='cyan cyan' diff

For completeness, the rest of options are:

  • context (context text - plain is a historical synonym)
  • meta (metainformation)
  • frag (hunk header)
  • func (function in hunk header)
  • old (removed lines)
  • new (added lines)
  • commit (commit headers)
  • whitespace (highlighting whitespace errors)
  • oldMoved (deleted lines)
  • newMoved (added lines)
  • oldMovedDimmed
  • oldMovedAlternative
  • oldMovedAlternativeDimmed
  • newMovedDimmed
  • newMovedAlternative
  • newMovedAlternativeDimmed
  • contextDimmed
  • oldDimmed
  • newDimmed
  • contextBold
  • oldBold
  • newBold

Available colors: normal, black, red, green, yellow, blue, magenta, cyan, white and default