Question

We have multiple developers working on a project. We're employing a feature-branch method of branching in which we do the following:

  1. All maintenance work and bug fixes are done on the trunk
  2. All new functionality is done on a new branch
  3. Branch is updated regularly (via merging changes from trunk to branch)

However, we've run into a situation that 2 branches [we'll call them feature-branch-1 and feature-branch-2] need to be merged together. What is the best way to accomplish this? Part of me thinks we should create a new branch. Then, merge that branch with the first feature branch [feature-branch-1]. And then merge with the second feature branch [feature-branch-2] and take care of the conflicts (which will most likely be the project files).

Is there a better way?

Thanks guys!

Was it helpful?

Solution

Oooh the merging. Love it.

If you mean you want to combine feature-branch-1, feature-branch-2 and trunk into some new branch then yes - your way is good. Otherwise I wouldn't waste precious time and just copy feature-branch-1 and merge feature-branch-2 into it. You've probably would've done it already instead of asking this question :D

OTHER TIPS

It depends somewhat on what you are trying to accomplish. Why do you want to merge two feature branches? If it's because the two features have logically "combined," just pick one to merge into the other, then do all your development on the merged branch. If it's because there are dependencies on items in the other branches, there is probably enough commonality still to merge into one branch, then only if truly needed, branch off the merged branch to develop a feature independently.

Keeping two non-trunk branches synchronized when they are for different features is likely to cause much pain; I wouldn't recommend it if you can help it.

I assume you regularly merge the trunk and the branches, don't you? If so, after that merge, the trunk and the branches are the same and you can just drop one of the branches and continue using the other one.

If you don't want to merge to the trunk, you can still merge one branch into the second and continue using the second.

Is merging the current state of one of the feature branches to trunk an option? If so, I recommend merging that feature branch to trunk and then updating the other feature branch to the latest in trunk. That way you avoid creating an additional branch and get rid of one of the branches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top