Print git commits body lines joined in one line

前端 未结 2 1480
[愿得一人]
[愿得一人] 2020-12-19 05:50

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

2条回答
  •  不知归路
    2020-12-19 06:12

    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
    

    List SHA1 IDs of commits in the branch.

        while read sha1; do
    

    Run a loop over every SHA1.

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

    Show the body of the commit.

            tr -d '\n'
    

    Remove all line endings.

            echo
    

    Add one newline at the end.

提交回复
热议问题