Svn merging trunk and branches

branchmergesvntrunk

I have a huge project.

I need to make a branch – this will be version 2 of the project, but I also need to keep the trunk and change it in parallel with the branch 1 as bug fix to the version 1.

I need to merge bug fixes from the trunk to the branch 1 while adding new features to the branch.

At the end I need to merge all changes back in the trunk and make new tag from it.

So I need bug fix for version 1, new branch for version 2 and of course merging bug fixes in the version 2.

I am using svn but the svn makes problems all the time. I cannot merge anything without conflicts.

Can someone give me an advice what to do?

Regards

Best Answer

Creating a branch for the purpose of providing bugfixes to older version is called a release branch. You should develop the bug fixes on trunk (because they need to go in all new versions right?). From there you merge them back to the versions that are still supported. That means that when version 1 is no longer supported, you stop merging bug fixes back to it. See the documentation for more info.

If a bugfix in trunk cannot be merged to the branch(es), the solution is to create a 'backport branch'. Here you either partially merge the fix from trunk, partially rewrite the same fix if the code is too different. It's also suggested to record the merges you would normally perform to fix the problem, so merge tracking helps you see wether or not the problem was fixed.

If you're fixing /branches/1.2.x, the naming convention the Subversion project uses is to create a backport branch called 1.2.x-r[REVNUM], where REVNUM indicates the revision you're backporting, or 1.2.x-issue[ISSUENUM], where ISSUENUM indicates the issue you're fixing.

When you're done creating the backport fix, you can merge it to the release with

svn checkout .../branches/1.2.x myproduct-1.2.x
svn merge --reintegrate .../branches/1.2.x-r123 myproduct-1.2.x

After reintegrating the branch, the branch should be deleted.