I currently format my Git log using the following pretty
definition:
[format]
pretty = format:%C(normal)%h %C(blue)%s %C(yellow)[%an]%C(reset)
This results in the output below:
Most of the time, I don't need to pay much attention to merge commits, so I have an alias that includes the --no-merges
flag by default:
I would actually prefer for merge commit log entries to always be present but be colored differently from non-merge commit log entries (so I can train my eye to skip them by default).
Is it possible to color merge commit log entries differently from non-merge commit log entries? If so, how do I achieve that?
You can achieve this with a git alias, using eg. sed.
[alias]
logo = "!logo(){ git log --pretty='format:<<%p>>%H %s %D' $@ | sed -e 's/<<[^ ]* [^ ]*\\( [^ ]*\\)*>>/\\x1B[36m/' -e 's/<<[^ ]*>>//' -e 's/$/\\x1B[0m/' | less -FRSX; }; logo"
The %p
specifier prints all the parents of the commit. The sed patterns recognize when there is more than one parent and replace that case with a color code. The color is reset at the end of each line.
The function wrapper and less give you the capability to pass git log parameters and restore paging, respectively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With