简体   繁体   English

如何将子分支提升为 Team Foundation Server 中的主干分支

[英]How to promote a child branch as the Trunk branch in Team Foundation Server

In Team Foundation Server we have several child branches and a Trunk branch.在 Team Foundation Server 中,我们有几个子分支和一个主干分支。 But now we need to promote a child branch as the Trunk branch and discard the current Trunk branch.但是现在我们需要将一个子分支提升为 Trunk 分支,并丢弃当前的 Trunk 分支。 Furthermore, we need to maintain the history of both the previous Trunk branch and the child branch.此外,我们需要维护之前的主干分支和子分支的历史记录。

PS: We cannot merge the current Trunk branch and child branch due to huge conflicts all over the project. PS:由于整个项目的巨大冲突,我们无法合并当前的Trunk分支和子分支。

Please go through the visual representation as well:请通过视觉表示 go 为好: 视觉表现

Even without knowing the entire context, this doesn't look like a good branching strategy in your environment.即使不了解整个上下文,这在您的环境中看起来也不是一个好的分支策略。

You want to reparent to other branch, you must set a relation ship between the 2 branches first.你想reparent到其他分支,你必须先在两个分支之间设置一个关系。

The only solution is baseless merging: tf merge /baseless After that, you will see the new target branch in the dialog.唯一的解决方案是 baseless 合并: tf merge /baseless之后,您将在对话框中看到新的目标分支。 More details info and steps please refer this blog: Reparent of a TFS Source Controlled Branch.更多详细信息和步骤请参阅此博客: TFS 源代码控制分支的父级。

You could also take a look at my reply in this question: TFS reparent to be a grandchild你也可以看看我在这个问题上的回复: TFS reparent to be a grandchild

We cannot merge the current Trunk branch and child branch due to huge conflicts all over the project.由于整个项目的巨大冲突,我们无法合并当前的主干分支和子分支。

Without actually updating any of the files on the child branch during the baseless merge, with the /discard switch set , has allowed us to create a relationship between the branches, without modifying the child branch and starting the relationship off with no pending merges between them:在 baseless 合并期间无需实际更新子分支上的任何文件,使用/discard开关设置,允许我们在分支之间创建关系,而无需修改子分支并在它们之间没有挂起合并的情况下启动关系:

tf merge $/Path/To/NewParent $/Path/To/Child /baseless /discard /recursive

You can then simply re-parent the child branch to the new parent branch.然后,您可以简单地将子分支重新设置为新的父分支。


Update更新

If you just want to replace the Trunk with child branch code.It's not able to achieve this simply from a merge process.如果您只想用子分支代码替换主干。仅通过合并过程无法实现这一点。 For example, we could not delete any files which only exist in trunk branch during merge process.例如,在合并过程中,我们无法删除仅存在于主干分支中的任何文件。 (From child → trunk) (从孩子→树干)

As a workaround, you could simply delete all codes/files in trunk branch first, then merge child branch back to trunk.作为一种解决方法,您可以先删除主干分支中的所有代码/文件,然后将子分支合并回主干。 After this, the Trunk branch will only have child branch code.在此之后,主干分支将只有子分支代码。

If you still need the old code in trunk, before delete files, you could create a new branch call "old trunk", merge code from trunk to it and make read only to keep tracking.如果您仍然需要主干中的旧代码,在删除文件之前,您可以创建一个新的分支调用“旧主干”,将主干中的代码合并到它并只读以保持跟踪。

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

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