Merging a branch of a branch into the trunk

  • 20 July 2021
  • 2 replies
  • 64 views

Userlevel 5
Badge +15

I have created a branch of a branch. For example I've branched the trunk project “Sandbox” to “Branch 1”. And then I've branched “Branch 1” to “Branch 2”, like the image below:

Then I start a merge session: merge branch 1 into the trunk. Then I want to merge branch 2 back into the trunk. However, it's not showing up by default in the merge session:

I can only select the recently merged “Branch 1” in “Branch project”, not the “Branch 2”. However, I can select the “Branch 1” as “Trunk project” when I remove some prefilters. Then I can merge Branch 2 into branch 1, and then merge branch 1 into the trunk.

Is this intended and safe to do?

I would expect I could merge branch 2 directly into the trunk as branch 1 is already merged.

Edit: 

What I actually want to do is update the branch 2 first with the latest trunk, continue developing and then merge it back.

Edit 2:

I also see in “Project versions” some fields, are they safe to change?

 


2 replies

Userlevel 7
Badge +23

Hi,

When making a branch (_2) of a branch (_1), the _1 branch becomes the Trunk of the _2 branch. That's why you can't select the Trunk project (Sandbox) when merging with _2. That is also the intended way.

It all has to do with the snapshot/base version (the original version/moment of branching) to identity differences in the branch and trunk versions. If we would allow branch_2 to be merged with Sandbox, the Software Factory would most likely fail to find new/changed/deleted objects.

The correct order is merging Branch_2 into Branch_1, thereafter merging Branch_1 into Sandbox.

Userlevel 5
Badge +15

This is a difficult one. In reality I have not 1 branch in between, but 3. The three branches in between are merged as described, but the still existing branch is not yet. However, this branch is outdated and should be preferrably updated with the latest trunk. So I want to update this branch, but this is not really efficient as I have to start a merge session from the trunk to branch 1, then a merge session from branch 1 to 2, then a merge session from 2 to 3 and finally from 3 to 4. And eventually merge it back to the trunk (same steps, other direction). I'm not sure how this will go due to the high amount of branches. It's not really like git that retargets the branch to the trunk.

I'm at a point I think it's more safe to create a new branch based on the trunk for the changes in branch 4, and try all over again. However that is also a lot of work.

Reply