How to Remove a Branch from the Middle of the Hierarchy?

谁说我不能喝 提交于 2019-12-05 00:28:11

The simplest solution is to not remove or reparent.

The service pack branch is the "service pack branch" in name only. Delete the "release" branch and rename the "service pack branch" to "release".

Branches in TFS are unfortunately old-fashioned (or, "Dinosaur-like" if you ask Torvalds ;) in that once created, the structure is set and cannot be changed. I believe you will have to create a new Release Branch directly below the Main, and then perform a baseless merge from the old Release branch to the new. I think you should use the /noprompt parameter to the merge command to stop the "Resolve Conflicts" dialog to show.

This will give you more conflicts than really needed, since TFS won't know what ancestor to use. But since you will want to take all from the original Release branch, you can use the command tf resolve /recursive /auto:TakeTheirs to tell TFS to always take the changes in the source branch.

After that, you should be able to remove the old branch tree.

Complicated, but not impossible.

Well I don't know about old version of TFS, but at least in TFS2012/VS2013, you can do:

  1. A Baseless merge from Main -> Release
  2. Source Control Explorer > Branching and Merging > Reparent, choose Main (the new parent)

Done!

The following worked for me in a similar scenario

tf merge /baseless /recursive /noprompt /discard $/TFS/Path/To/Release $/TFS/Path/To/Main

then:

  • delete "Service Pack" branch
  • check-in "Main" and "Service Pack"

now you can do normal GUI merges from "Release" to "Main"

NOTE: As many people already have mentioned, be careful with baseless merges they can bite you in the jewels later on down the line when abused.

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