Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reproduce the format of git log --oneline --decorate?

Tags:

git

git-log

Where is the format of git log --oneline --decorate defined?

Using git Iog --format=format:'my format', I cannot reproduce the colours of the branches, tags and HEAD as shown by git log --oneline --decorate.

 git log --oneline --decorate    

shows HEAD in light blue, the branch names in green and the punctuations (,,) in brown.

The closest I have come to getting what I want is:

git log --graph --abbrev-commit --decorate --date=short --format=format:'%C(bold blue)%h%C(reset) %C(bold green)%ad%C(reset)%d %C(white)%s%C(reset)' -20  

with the only difference being that the branches/HEAD/tags are not coloured like with the previous command.

like image 826
augustin Avatar asked Feb 07 '23 00:02

augustin


1 Answers

It does not appear to be possible with git version < 1.8.3.

Since git 1.8.3, one could use the colour %C(auto) token:

   git log --graph --decorate --date=short --format='%C(bold blue)%h%C %C(bold green)%ad %C(auto)%d  %C(white)%s%C(reset)' -10   

The key element being:

%C(auto)%d ...  %C(reset) 

See also:

Color in git-log
Git pretty format colors

like image 62
augustin Avatar answered Feb 08 '23 14:02

augustin