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.
For example, with two commits A and B, command:
$ git log --format=%b
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With