如何为分支中的所有提交生成补丁? [英] How to generate patch for all commits in a branch?
问题描述
如何仅通过了解分支名称来为给定分支中的所有提交生成补丁?
How can I generate patch for all commits in a given branch by knowing only the branch name?
此步骤是复杂工作流程的一部分,所有工作流程均已自动化.因此,要求某人手动确定分支中的第一次提交不是一种选择.
This step is part of a complex workflow all of which is being automated. Hence requiring someone to manually determine the first commit in the branch is not an option.
请注意,任何依赖于reflog的选项都不是一种选择,因为分支的更改不是在本地进行的.
Note that anything relying on reflog is not an option either because changes in the branch are not made locally.
推荐答案
如果您知道给定分支"来自哪个分支,已创建,然后制作补丁很容易:
If you know from which branch your "given branch" has been created, then making a patch is easy:
git diff master Branch1 > ../patchfile
git checkout Branch2
git apply ../patchfile
(您也可以生成也可以在没有git的情况下应用补丁)
但是找到正确的创建提交"分支的过程可能很复杂:请参见"使用Git查找分支点?"
But finding the right "creation commit" of a branch can be complex: see "Finding a branch point with Git?"
使用的 OP akirekadu :
git format-patch $(git merge-base --fork-point master)..branchB
您可以在" git diff
在工作副本和分支机构之间使用它"
You can see it used in "git diff
between working copy and branch base"
legends2k 添加了
一个人可以使用 One can verify the generated patch with
警告: AGP 注释
这篇关于如何为分支中的所有提交生成补丁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!git apply --stat patchfile
验证生成的补丁
这将不适用,但会提供补丁的详细信息.
git apply --stat patchfile
This won't apply, but give the details of the patch.
$(git merge-base --fork-point master)..branchB
命令可能每次都找不到正确的分支根修订版
$(git merge-base --fork-point master)..branchB
command may not find the correct branch root revision every time