我正在使用以下自定义日志格式来查看我的提交:
命令: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
除了我希望提交正文与提交标题对齐外,它工作得很好。是否可以只使用git来实现?
最佳答案
您可以使用 %w(<your max line width>,<first line indent>,<second line indent>)
在消息正文前面,例如
%w(64,16,16)%b
来自 pretty format documentation :
'%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of git-shortlog[1].
来自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.
不能说如何删除尾随的换行符,但我想它可能有一些额外的格式说明符。有用于从占位符中去除前面的换行符的选项,但没有用于尾随换行符的类似选项。
关于git 日志格式 : shift commit body X columns to the right,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33806068/