'How to get ref names with git log --pretty=format:"...."? %d shows refs, but all in same color

I'm trying to get a customized git log listing using --pretty=format:"....", but can't seem to find out how get the ref names colored as in git log --oneline. This is my log command so far:

git log --pretty=format:"%C(yellow)%h%Creset %d %ci (%cr)%n    ==> %s%n"

It displays all I want, except for the coloring of the refs:

enter image description here

Is there a way to get the refs printed in color such as in git log --oneline?

enter image description here



Solution 1:[1]

Use of %C directives disables automatic colorization unless you re-enable it with %C(auto). You can just replace the %Creset part with %C(auto) (per testing).

So the final command for your case will be:

git log --pretty=format:"%C(yellow)%h%C(auto) %d %ci (%cr)%n    ==> %s%n"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Trolzen