特定作者的 git format-patch X..Y

标签 git patch

我想知道您是否可以为一个范围生成补丁,但仅限于来自特定作者的提交,就像您使用 git log --author='bob' 一样。

最佳答案

是的,这是可能的。

根据 referencegit 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/

相关文章:

git - 如何在 git add 之前自动调用脚本?

git - 为什么 git grep 中的文件 glob **/*.cs 不显示所有 *.cs 命中?

git - 如何通过 Pull Request 执行 git 回滚?

c++ - 需要帮助为 std 字符串应用 MinGW 补丁,得到意想不到的结果

open-source - 为我自己的开源项目赢得用户和贡献者的最佳方法是什么?

diff - 如何为整个目录创建补丁来更新它?

patch - 如何修补 --dry-run 但仍然查看拒绝?

Linux - 有什么方法可以配置或创建脚本/程序来右键单击而不选择菜单项?

Git 克隆到一组空目录中

具有相同名称但大小写不同的文件的 Git rebase 问题