Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a custom git log format that I use. I have color.ui=true set in my .gitconfig. For example this simple format:

git log --pretty=format:"%h %d %s" --decorate

This would print something like

52a41e0 (HEAD, local) Commit message foo
185bd17 (remote) The commit message

HEAD, local, remote will be output without color compared to git log --oneline --decorate which will outupt HEAD (in 'bold cyan'), local (in 'bold green') and remote (in 'bold red') with color. Now I can wrap the %d with something like %Cred%d%Creset which will cause all ref names to be red.

How can I get current, local, and remote ref names to have seperate colors when using a custom format with git log?

share|improve this question
    
I don't think it is possible: stackoverflow.com/questions/5889878/color-in-git-log/… –  VonC Sep 21 '11 at 3:58
    
Ack, didn't look on stack overflow. That's too bad though. –  Tiggerizzy Sep 21 '11 at 4:27
    
@VonC Maybe you should add that as an answer? –  N.N. Sep 21 '11 at 20:53
    
@N.N. I have. On Stack Overflow. About one of the 10 thousands questions on Git. –  VonC Sep 21 '11 at 21:06
add comment

2 Answers

up vote 4 down vote accepted

You can now use %C(auto) as of git 1.8.3, according to this Atlassian blog post;

git log --format=format:'%h%C(auto)%d%C(reset) %s (%an, %ar)'

gives

enter image description here

— Again, courtesy of VonC on "Color in git-log", reposted here for the convenience of inbound googlers.

share|improve this answer
add comment

The git log --decorate will put by default:

  • the HEAD in cyan
  • the remote branches in red
  • the tag in green

and can be changed through color.decorate config.

But the git log --format don't offer a way to display specifically the HEAD or remotes or branch: all three are displayed through %d, with one color possible.

VonC on "Color in git-log"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.