简体   繁体   English

如何将git分支合并到多个发布分支

[英]How to merge a git branch to multiple release branches

After a tfs migration (totally different concept of branches) I have to merge fixes to multiple release branches, but the branches are not identical, they are mostly similar, but different products(eg different branding, conn strings etc. ), so i can't use nvie gitflow one product branching strategy here. 在tfs迁移(完全不同的分支概念)之后,我必须将修复程序合并到多个发布分支,但是分支不完全相同,它们大多相似,但是不同的产品(例如,不同的品牌,conn字符串等),所以我可以在这里使用nvie gitflow一个产品分支策略。

在此输入图像描述

https://github.com/MrKekson/stackoverflow_question/network https://github.com/MrKekson/stackoverflow_question/network

here you can find a greatly simplified branch structure, and basically I want to merge the hotfix1 branch from b1, to tesztb3, but without the previous commits on b1 (c3, c4). 在这里你可以找到一个大大简化的分支结构,基本上我想将b1的hotfix1分支合并到tesztb3,但没有先前的b1(c3,c4)提交。

Cherrypicking or rebase could help, but i did not managed to get it done, and i did not have a lot of experience in advanced git usage yet. Cherrypicking或rebase可能有所帮助,但我没有设法完成它,我还没有很多高级git使用经验。 So please advise me on how to do it, or what should i change to get it done. 所以请告诉我如何做,或者我应该改变什么才能完成它。

Ok, i solved it. 好的,我解决了。 There are at least a few ways to do it: 至少有几种方法可以做到:

So basically, one can cherry-pick every commit separately on hotfix1 to teszt3, but it's clumsy. 所以基本上,人们可以在hotfix1上分别挑选每个提交到teszt3,但它很笨拙。

So we can either create a merge branch from b1, merge hotfix1 into it, then cherry-pick the commit created by the merge into tesztb3, what will yield a new commit on testb3. 因此,我们可以从b1创建合并分支,将hotfix1合并到其中,然后将合并创建的提交选择到tesztb3,什么将在testb3上产生新的提交。 One can even add -x to the cherry-pick, so itt will create a note on the new commit, with it's parents guid, alternatively we can squash our hotfix1 branch into 1 commit, and then cherry-pick that. 甚至可以将-x添加到cherry-pick中,因此它会在新提交中创建一个注释,它的父母是guid,或者我们可以将我们的hotfix1分支压缩为1个提交,然后挑选它。

Or we can create a rebase branch based on the the last commit(hf2), then 或者我们可以根据最后一次提交(hf2)创建一个rebase分支

git rebase --onto <new-parent> <old-parent> <lastcommit> 

--onto explained here , but <new-parent> is our target branch teszt3, i prefer creating a merge branch for this on the target branch, old parent is the start of hotfix1, and lastcommit in this case is hf2 on hotfix1. - 这里解释一下 ,但是<new-parent>是我们的目标分支teszt3,我更喜欢在目标分支上为此创建一个合并分支,旧的父级是hotfix1的开始,在这种情况下,lastcommit是hotfix1上的hf2。 Then merge teszt3 to our new merge branch, and create a pull request back to teszt3. 然后将teszt3合并到我们的新合并分支,并创建一个拉回请求到teszt3。

So i think neither path is easy at first look, but doable with a bit experience, and event this is a way smoother experience then renaming a directory in tfsvc. 所以我认为一开始看起来这两条路都不容易,但是有点经验可以做到,事件这是一种更顺畅的体验,然后重命名tfsvc中的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM