git 日志格式 : shift commit body X columns to the right

标签 git format

我正在使用以下自定义日志格式来查看我的提交:

命令: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/

相关文章:

git 远程 url 自动重置

git - merge 而不 merge 分支提交历史 sourcetree

JavaScript 日期 : toGMTString, 也是 ISO 8601 格式?

c# - 有没有一种简单的方法可以用 string.format 只写非空参数

format - 为什么 Lisp 中的单引号总是返回大写字母?

git - 从命令行添加换行符到 'git commit -m'

验证连接时 git 权限被拒绝(公钥)

python - 在我的 python 项目中使用我自己的模块的最佳方式

xslt - 在 xsl 中格式化科学数字表示

multithreading - 为什么说 "Don' t 同时格式化软盘的评论在谈论线程和进程时很有趣?