Git - 为分支中的所有提交生成补丁 [英] Git - generate patch for all commits in a branch

查看:295
本文介绍了Git - 为分支中的所有提交生成补丁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过只知道分支名称来为给定分支中的所有提交生成补丁?



这一步是复杂工作流程的一部分,所有这些都是自动化。因此,需要某人手动确定分支中的第一次提交不是一个选项。



请注意,任何依赖reflog的选项都不是一种选择,因为分支中的更改不是如果你知道你的给定分支是从哪个分支创建的,那么

  git diff:

主分支1> ../patchfile
git checkout Branch2
git apply ../patchfile

(并且您可以生成一个补丁,但不能使用git



但找到分支的正确创建提交可能很复杂:请参阅使用Git查找分支?



使用的

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

您可以在 git diff 在工作副本和分支库之间


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.

解决方案

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"

这篇关于Git - 为分支中的所有提交生成补丁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆