With something like git log --abbrev-commit --pretty=format:'%h %<(72,trunc)%s %d'
, you can get a fairly well aligned git commit message with a graph. It is completely aligned if you drop the --graph
option. Here is roughly what the command looks like
* 40f1481 Commit title message (HEAD, dev)
|\
| * 9b5122d Commit title message (debug)
| * fe7ddfe Commit title message
| * 8e4d414 Commit title message
| * 53affdd Commit title message
| * a45fbaf Commit title message
|/
* 36b23c3 Commit title message
* 5b7bfe1 Commit title message (master)
The issue is that with the graph symbols the alignment is messed up, as you can see in the first two commits. Here is what it should ideally look like
* 40f1481 Commit title message (HEAD, dev)
|\
| * 9b5122d Commit title message (debug)
| * fe7ddfe Commit title message
| * 8e4d414 Commit title message
| * 53affdd Commit title message
| * a45fbaf Commit title message
|/
* 36b23c3 Commit title message
* 5b7bfe1 Commit title message (master)
My question is there an option for getting the correct alignment when using the graphing option? Or to get the width of the graph so that you can pad the log accordingly?
I know a quick hack would be to just pad the first option by tab (%x09), and it should work for probably most projects, but I'm wondering if their is a aesthetically superior, foolproof option that gets by with the minimum padding but also works in cases where 5 wouldn't be enough. Here is an example where the tab solution fails
Log with using columns, without colored graph.
Complete success! Will try to update later.
Modern versions of Git (I have git 2.17.0 on cygwin environment) work fine with colorized graph and indentation without any additional tools or scripts.
My .gitconfig
aliases part:
[alias]
l = log --graph --abbrev-commit --decorate=no --date=format:'%Y-%m-%d %H:%I:%S' --format=format:'%C(03)%>|(26)%h%C(reset) %C(04)%ad%C(reset) %C(green)%<(16,trunc)%an%C(reset) %C(bold 1)%d%C(reset) %C(bold 0)%>|(1)%s%C(reset)' --all
I have tested it on django official repository and it works great:
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