[英]VSTS Git merge grandchild branch into master after child branch has been merged back into master
We had a long-running branch branch1, branched off of master, that was undergoing a full regression test, which took a while. 我们有一个长期运行的分支branch1,它是从master分支出来的,它正在接受完整的回归测试,这花了一段时间。
While that was being tested, I was working on a feature which required changes in branch1, call it branch1a, which was branched off of branch1. 在测试该功能时,我正在开发一项功能,该功能需要在branch1中进行更改,将其称为branch1a,它是从branch1分支出来的。 I'm still working on that but it should be done soon TM . 我仍在努力,但应该尽快完成TM 。
This morning, branch1 testing was finished and it was merged back into master. 今天早上,branch1测试完成,并且被合并回master。 We're using VSTS. 我们正在使用VSTS。 I'm not exactly sure how it was merged (rebase, squash, etc.). 我不确定它是如何合并的(变基,压扁等)。 There is a PR which lists a bunch of commits and other PRs for branch1. 有一个PR列出了branch1的一堆提交和其他PR。 It looks like it shows up as 1 commit in master history. 在主历史记录中看起来像是1次提交。
Now I'm not really sure what to do when I'm done, my parent branch is sort of gone, but sort of not. 现在我不太确定完成后该怎么做,我的父分支已经消失了,但是没有。 If I create a PR versus master I get 400 files changed, if I create it vs branch1 I get 12 files changed. 如果我创建PR与主控,则可以更改400个文件,如果创建PR与master1,则可以更改12个文件。
It looks like a merge will use the common parent, before branch1 was branched, instead of where I branched branch1a off of branch1, which seems like it might result in a lot of problems (though, technically, there are only a few changes in the actual most recent files). 看起来合并将在分支1分支之前使用公共父级,而不是我在分支1分支出分支1a的位置,这似乎可能会导致很多问题(尽管从技术上讲,实际的最新文件)。
Would a rebase instead of a merge make more sense here? 在这里,重新合并而不是合并更有意义吗? My commits should replay pretty cleanly against what is now master (if I understand rebase correctly). 我的提交应该与现在掌握的内容相当清晰地重播(如果我理解正确的变基)。
We have policies in VSTS such that we can't commit directly to master--we need to use PRs. VSTS中有一些政策,因此我们无法直接提交给master,我们需要使用PR。 I'm not sure if I can create a PR that uses rebase...maybe I should branch master, branch2, and rebase my branch to branch2, then make a PR to master from branch2? 我不确定是否可以创建使用rebase的PR ...也许我应该将master,branch2分支,然后将我的分支重新部署到branch2,然后再将PR从branch2变为master?
It will help to think like git thinks; 像git一样思考会有所帮助; so in that sense, branch1
is not "sort of gone". 所以从这个意义上说, branch1
并不是“消失了”。 It either has been deleted and is gone, or it has not been deleted and is not gone. 它要么已被删除并消失了,要么尚未被删除并没有消失。 From what you describe, I think the latter. 根据您的描述,我认为是后者。
To really be sure, you should find out how the branch was combined with master
. 确实可以确定,您应该了解分支如何与master
结合。 I suspect it was just merged. 我怀疑它只是合并了。 Depending on how you look at master's history, you might (or might not) describe the result of a merge as "a single commit". 根据您对主人历史的了解,您可能会(也可能不会)将合并结果描述为“单次提交”。 (The documentation for squash can be confusing in this regard, IMO.) (在这方面,IMO的壁球文档可能会造成混淆。)
Does that singe commit have a 2nd parent? 那个单身犯有第二个父母吗? If so it's a true merge. 如果是这样,那是一个真正的合并。 If not it's a squash (and that will make things harder). 如果不是,那是壁球(这会使事情变得更困难)。 If it's only one commit, it's not a simple rebase (but a squash is really just a special type of rebase, so that's splitting hairs I guess). 如果只是一次提交,那不是一个简单的变基(但是壁球实际上只是一种特殊的变基,所以我猜这很麻烦)。
If it's a true merge, everything is fine. 如果这是真正的合并,那么一切都很好。 You can merge branch1a
to master
; 您可以将branch1a
合并为master
; at most this might make conflict resolution a little more intimidating. 至多这可能会使解决冲突更加令人生畏。 If you want to break that into smaller pieces of conflict resolution work (or if you just want to maintain a sense of symmetry in the branch topology), you can merge branch1a
to branch1
and then merge branch1
to master
again. 如果您想将其分解为较小的冲突解决工作(或者只是想在分支拓扑中保持对称感),则可以将branch1a
合并到branch1
,然后再将branch1
合并到master
。
I would not expect a rebase to make things any easier, and if any of the branch1a
commits have been pushed to a remote repo then I recommend against rebasing. 我不希望通过变基使事情变得更容易,并且如果任何branch1a
提交都已推送到远程存储库,那么我建议不要变基。 At any rate, the reason to rebase is if you want a more linear history, which some people find cleaner (even though it might create unbuildable intermediate states). 无论如何,重新设定基准的原因是是否需要更线性的历史记录,有些人会找到更清晰的历史记录(即使它可能会创建不可构建的中间状态)。
As for your last paragraph... you're making things too complicated for yourself with that idea. 至于最后一段……您正在用这个想法使事情变得过于复杂。 There's just no need. 根本没有必要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.