打印git提交身体线加入一行 [英] Print git commits body lines joined in one line

查看:136
本文介绍了打印git提交身体线加入一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何打印git提交只打印正文(不带标题的提交消息),但在一行中?因此,提交正文行被连接,可能以空格分隔,并且打印为一行提交。

How can I print git commits to print only body (commit message without title) but in one line? So commit body lines are joined, possibly separated with space, and printed as one line for one commit.

例如,有两个提交A和B,命令:

For example, with two commits A and B, command:

$ git log --format=%b

print:

prints:

Commit A, line A.1
Commit A, line A.2
Commit B, line B.1
Commit B, line B.2

但我想得到:

But I'd like to get:

Commit A, line A.1 Commit A, line A.2
Commit B, line B.1 Commit B, line B.2


推荐答案

git rev-list master |
    while read sha1; do
        git show -s --format='%B' $sha1 | tr -d '\n'; echo
    done

让我解释一下:

Let me explain:

git rev-list master

列出SHA1 ID

List SHA1 IDs of commits in the branch.

    while read sha1; do

对每个SHA1运行循环。

Run a loop over every SHA1.

        git show -s --format='%B' $sha1

显示提交的主体。

        tr -d '\n'

删除所有行结束符。

Remove all line endings.

        echo

最后添加一个换行符。

这篇关于打印git提交身体线加入一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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