git日志格式:将提交主体X列向右移动 [英] git log format: shift commit body X columns to the right

查看:70
本文介绍了git日志格式:将提交主体X列向右移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using the following custom log format to view my commits:

命令: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来实现?

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?

推荐答案

您可以在邮件正文前面使用%w(<your max line width>,<first line indent>,<second line indent>),例如

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

来自漂亮格式文档:

'%w([<w>[,<i1>[,<i2>]]])': switch line wrapping, like the -w option of git-shortlog[1].

并且来自简短日志:

-w[<width>[,<indent1>[,<indent2>]]]

通过按宽度包装每行来换行输出.每个条目的第一行以indent1空格缩进,第二行和后续行以indent2空格缩进. width,indent1和indent2分别默认为76、6和9.

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.

如果width为0(零),则使输出的行缩进而不包裹它们.

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.

这篇关于git日志格式:将提交主体X列向右移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆