2

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.

Please go through the visual representation as well: Visual representation

Sachith Wickramaarachchi
  • 5,546
  • 6
  • 39
  • 68

1 Answers1

0

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.

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Without re-parenting the branch, is there a way to replace the Trunk with child branch code? Basically is there anyway to override the Trunk code? – Shehani Kalapuge Oct 15 '19 at 05:03
  • Hi Shehani Kalapuge, not able to achieve this simply from a merge process. For example, we will not be able to delete any files which only exist in target branch during merge process (From child → trunk). As a workaround, you could delete all codes/files in trunk branch, then merge child branch back to trunk. After this the Trunk branch will only have child branch code. – PatrickLu-MSFT Oct 15 '19 at 06:11
  • Hi Shehani Kalapuge, any update for this ticket? Do you still have any concern on it? If my reply helped or gave a right direction. Appreciate for [marking it as an answer](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) which will also help others in the community. – PatrickLu-MSFT Nov 01 '19 at 06:29
  • "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." this approach works thanks a lot – Shehani Kalapuge Nov 06 '19 at 05:35