I was wondering if you can generate patches for a range but only limit to commits from a specific author, the way you do with git log --author='bob'
.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Yes, it is possible.
According to reference on git format-patch
it accepts <revision range>
Generic expression (see "SPECIFYING REVISIONS" section in gitrevisions(7)) means the commits in the specified range.
Details may be found in the reference but we only need this one:
^!, 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).
So you'll need:
git log X..Y --author='<AUTHOR>' --format="%H" | sed 's/$/^!/g' | xargs -I{} git format-patch {}
git log X..Y --author='<AUTHOR>' --format="%H"
produces output in format of 40-digit sha1 sums.
sed 's/$/^!/g'
adds ^! at the end of each line
xargs -I{} git format-patch {}
just runs git format-patch
with each line