I'm using the following custom log format to view my commits:
Command: git log --pretty=format:"%C(auto)%h %<(8,trunc)%aN %Cgreen%s %+b"
3758d35 Daniel This commit does nothing
You really should remove it before commiting.
1. This is a line
2. This is another line
a191c2b Daniel Viral helvetica lomo, typewriter fashion axe
814a6a9 John Umami pork belly pickled, fanny pack yr keffiyeh fap YOLO
d5e130e Daniel Cardigan raw denim banjo
f7107d8 Daniel 90's ramps pinterest, craft beer blue bottle
It works great except I'd like the commit body to be aligned with the commit title. Is it possible to achieve using only git?
You can use %w(<your max line width>,<first line indent>,<second line indent>)
in front of the message body, e.g.
%w(64,16,16)%b
From pretty format documentation:
'%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of git-shortlog[1].
And from shortlog:
-w[<width>[,<indent1>[,<indent2>]]]
Linewrap the output by wrapping each line at width. The first line of each entry is indented by indent1 spaces, and the second and subsequent lines are indented by indent2 spaces. width, indent1, and indent2 default to 76, 6 and 9 respectively.
If width is 0 (zero) then indent the lines of the output without wrapping them.
Can't say how to drop the trailing newline, but I guess it might be possible with some additional format specifier. There are options for stripping preceding newlines from a placeholder, but no similar option for a trailing one.
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