我想知道您是否可以为一个范围生成补丁,但仅限于来自特定作者的提交,就像您使用 git log --author='bob'
一样。
最佳答案
是的,这是可能的。
根据 reference在 git format-patch
它接受 <revision range>
Generic expression (see "SPECIFYING REVISIONS" section in gitrevisions(7)) means the commits in the specified range.
详细信息可以在 reference 中找到但我们只需要这个:
^!, e.g. HEAD^!
A suffix ^ followed by an exclamation mark is the same as giving commit and then all its parents prefixed with ^ to exclude them (and their ancestors).
所以你需要:
git log X..Y --author='<AUTHOR>' --format="%H" | sed 's/$/^!/g' | xargs -I{} git format-patch {}
git log X..Y --author='<AUTHOR>' --format="%H"
以 40 位 sha1 和的格式生成输出。
sed 's/$/^!/g'
添加^!在每行的末尾
xargs -I{} git format-patch {}
刚刚运行 git format-patch
每行
关于特定作者的 git format-patch X..Y,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28891595/