In Team Foundation Server we have several child branches and a Trunk branch. But now we need to promote a child branch as the Trunk branch and discard the current Trunk branch. 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.
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.
The only solution is baseless merging: tf merge /baseless
After that , you will see the new target branch in the dialog. More details info and steps please refer this blog: Reparent of a TFS Source Controlled Branch.
You could also take a look at my reply in this question: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:
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.
来源:https://stackoverflow.com/questions/58298903/how-to-promote-a-child-branch-as-the-trunk-branch-in-team-foundation-server