Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reparenting a child branch to its grand-parent

I have the following branch structure:

- Main
   |- Release 1
      |- Release 1.1
   |- Release 2

I want to reparent Release 1.1 to Main so it looks like

- Main
   |- Release 1
   |- Release 1.1
   |- Release 2

The reason I want to do this is because many changesets will need to be merged from Main to Release 1.1 but not to Release 1

I have been trying to do a baseless merge from Main to Release 1.1 using the following command:

tf merge /recursive /baseless $/Main $/Releases/Release1.1

It works great, once it is checked in, I can reparent Release 1.1 to Main.

But the thing is, this command merges everything from Main and I just want to create a merge relationship. I don't want to merge everything from Main to Release 1.1 since many other changes for other branches have occurred meanwhile.

Is there a way to achieve that or will all the future changesets need to be baseless merged every single time?

like image 264
user1601700 Avatar asked Mar 23 '14 21:03

user1601700


2 Answers

Based on James Reed comment, the cleanest way to create a merge relationship between the two branches is to simply remove the /recursive parameter:

tf merge /baseless $/Main $/Releases/Release1.1

The merge will then only contain the targeted branch root folder, which you can check in without any other change, without having to cherry pick change sets.

like image 135
PhilDulac Avatar answered Oct 16 '22 22:10

PhilDulac


To merely create the relationship [and not merge everything] we will need to perform a baseless selective merge from Parent to potential child branch by passing selected changeset numbers. This may be achieved via the GUI by following the below steps as mentioned in the blogpost: http://roadtoalm.com/2012/09/19/reparent-of-a-source-controlled-branch-why-and-how/

Though this blog talks about reparenting wherein we merge all the changes from the potential parent branch to a child branch… but there will be times when we do not need all the changes from the new parent branch. What do we do then? The idea is to go ahead and select all the changes and merge them to the child branch and then undo pending changes for the changes that are not required. Once all the unwanted changes are un-done, go ahead and check-in. Then as per the blog we would need to set the reparent option to the new parent. I know its not a clean approach but this works!

like image 4
Sourav Kundu Avatar answered Oct 16 '22 21:10

Sourav Kundu