如何只输出 git rev-list 的“--pretty=”部分?
How to output only the "--pretty=" part of git rev-list?
git rev-list --pretty='%H %an <%ae> %at' origin/topic-branch ^origin/master
输出如下:
commit d2d0b50ceac50cc81cf991ce09ab3db134af751d
d2d0b50ceac50cc81cf991ce09ab3db134af751d John Doe <john@doe.com> 1592392426
commit c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1
c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1 John Doe <john@doe.com> 1592393061
所需的输出应仅包含漂亮格式的占位符组成的字符串,如下所示:
d2d0b50ceac50cc81cf991ce09ab3db134af751d John Doe <john@doe.com> 1592392426
c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1 John Doe <john@doe.com> 1592393061
我不知道如何摆脱 rev-list
打印的默认行。
git rev-list origin/topic-branch ^origin/master |
while read sha1; do
git --no-pager show -s --pretty='%H %an <%ae> %at'
done
技巧的主要部分是 git show -s
,它跳过提交 headers 并且只打印漂亮的部分。
git rev-list --pretty='%H %an <%ae> %at' origin/topic-branch ^origin/master
输出如下:
commit d2d0b50ceac50cc81cf991ce09ab3db134af751d
d2d0b50ceac50cc81cf991ce09ab3db134af751d John Doe <john@doe.com> 1592392426
commit c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1
c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1 John Doe <john@doe.com> 1592393061
所需的输出应仅包含漂亮格式的占位符组成的字符串,如下所示:
d2d0b50ceac50cc81cf991ce09ab3db134af751d John Doe <john@doe.com> 1592392426
c5e1438a6ef2e6090c3f9dd9df0a5834b32b50b1 John Doe <john@doe.com> 1592393061
我不知道如何摆脱 rev-list
打印的默认行。
git rev-list origin/topic-branch ^origin/master |
while read sha1; do
git --no-pager show -s --pretty='%H %an <%ae> %at'
done
技巧的主要部分是 git show -s
,它跳过提交 headers 并且只打印漂亮的部分。