How to emulate git log --decorate's different colors per branch-type

GitGit Config

Git Problem Overview


In making my favorite git log view I've created this alias:

graph = log --pretty=format:'%Cgreen%ad%Creset %C(yellow)%h%Creset%C(yellow)%d%Creset %s %C(cyan)[%an]%Creset %Cgreen(%ar)%Creset' --date=short --graph

This creates an output like:

Git log result with own coloring

What I'm missing here is the different coloring of branch types like in log --oneline --decorate --graph.

Git log result with --decorate(=short)

The --decorate (which uses =short by default) gives the different recognized branches a different color. The branch types (HEAD, origin/master, origin/HEAD, master) are colored cyan, red, red, green. Mine however are uncolored; colored only with the yellow of the whole branches part.

Is there a way to give different colors to the different kind of branches with an own alias?

Git Solutions


Solution 1 - Git

Per https://stackoverflow.com/a/16844346/55948

> As of git 1.8.3 (May 24, 2013), you can use %C(auto) to decorate > %d in the format string of git log. > > From the release > notes: > > * "git log --format" specifier learned %C(auto) token that tells Git > to use color when interpolating %d (decoration), %h (short commit > object name), etc. for terminal output.)

Solution 2 - Git

I don't believe this is possible. Looking through the git-log(1) man page, the only relevant format for --pretty seems to be %d, which gives you all the ref names. Since there aren't any options which distinguish the type of reference, you can't give each type a different color.

See also this question.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLodeView Question on Stackoverflow
Solution 1 - GitkenwarnerView Answer on Stackoverflow
Solution 2 - GitTrebor RudeView Answer on Stackoverflow