Git pretty format colors

I do not have an old version of git to verify that the colors other than red, blue and green are supported.

Although, one thing I noticed even with the recent versions of git (like 1.7.10 I used) is that colors other than red, green and blue need to be within parentheses (). For red, green and blue, the parentheses are optional.

So give this a try:

git log --pretty=format:"%Credred%Creset %Cgreengreen%Creset %C(Yellow)yellow%Creset %Cblueblue%Creset %C(magenta)magenta%Creset %C(cyan)cyan%Creset %C(white)white%Creset"

The list of colors I’m aware of at least are:

normal
black
red
green
yellow
blue
magenta
cyan
white

It can be combined with one of these attributes:

bold
dim
ul
blink
reverse
italic
strike
bright  # (Git 2.26, Q1 2020, example: brightred)

If you’re trying to change colors using .gitconfig you should be able to specify two colors – foreground and background and you can combine it with an attribute.

Leave a Comment

tech