ely*_*ely 2 git github git-log git-commit
如果您在文档中搜索 %b 和 %B ,除了神秘的“(未包装的主题和正文)”之外,没有解释它们之间的区别。
这是来自 repo 的示例提交(使用 git 版本 2.9.3)以及使用 %b 与 %B 打印的不同结果。提交命令是git commit -m 'Automated version update from Jenkins.'
$ git log -1 origin/master
commit 30ac57e...
Author: Jenkins <email@email.com>
Date: Wed Jul 12 16:28:41 2017 +0000
Automated version update from Jenkins.
$ git log -1 --format=%B origin/master
Automated version update from Jenkins.
$ git log -1 --format=%b origin/master
$
Run Code Online (Sandbox Code Playgroud)
我不明白为什么 %b 无法生成提交消息正文,也不明白为什么 %B (如果它在某种意义上包含“主题和正文”)只提供消息正文。
从日志进行漂亮打印的 %b 和 %B 之间的根本区别是什么?
如果您只想可靠地打印最近的提交消息(仅消息),您应该怎么做?我认为应该是,git log -1 --format=%b origin/master但这个例子似乎表明并非如此。%B 是否可靠地工作,或者短语“(展开的主题和正文)”是否意味着在某些情况下它可能以某种方式包含主题?
提交你正在寻找不有身体,所以%b正确打印什么。“主题”,在同一文档的其他地方也称为“标题行”,是标题和下一个空白行之间的所有内容,这是您提交的唯一一种消息。正文是从第一个空行开始的所有内容。
用不同的提交说明:
$ git log -1 51e6467fdc073a9a5149b4c12ca9d79d6ac46872^!
Run Code Online (Sandbox Code Playgroud)
commit 51e6467fdc073a9a5149b4c12ca9d79d6ac46872
Author: Andrew Rodland <andrew@cleverdomain.org>
Date: Fri Mar 14 14:22:02 2014 -0400
Make the event data be the master that owns the socket, instead of the socket
Then we will be able to access the master's domains and other info later
on
Run Code Online (Sandbox Code Playgroud)
$ git log --format=%B 51e6467fdc073a9a5149b4c12ca9d79d6ac46872^!
Run Code Online (Sandbox Code Playgroud)
Make the event data be the master that owns the socket, instead of the socket
Then we will be able to access the master's domains and other info later
on
Run Code Online (Sandbox Code Playgroud)
$ git log --format=%b 51e6467fdc073a9a5149b4c12ca9d79d6ac46872^!
Run Code Online (Sandbox Code Playgroud)
Then we will be able to access the master's domains and other info later
on
Run Code Online (Sandbox Code Playgroud)
“解包”只是意味着主题将删除任何换行(尽管约定它无论如何都不应长于一行,git 不强制执行)。
| 归档时间: |
|
| 查看次数: |
254 次 |
| 最近记录: |