Git - generate patch for all commits in a branch

倖福魔咒の 提交于 2019-12-03 03:27:53

问题


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.

Note that anything relying on reflog is not an option either because changes in the branch are not made locally.


回答1:


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

(and you can generate a patch applicable without git too)

But finding the right "creation commit" of a branch can be complex: see "Finding a branch point with Git?"

The OP akirekadu used:

git format-patch $(git merge-base --fork-point master)..branchB 

You can see it used in "git diff between working copy and branch base"



来源:https://stackoverflow.com/questions/42800902/git-generate-patch-for-all-commits-in-a-branch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!