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

1

5

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

Archeozoic answered 3/12, 2021 at 19:23 Comment(0)
N
7

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"
Nuclear answered 4/12, 2021 at 0:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.