Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Svn merging trunk and branches

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

like image 742
Darko Petreski Avatar asked Mar 09 '10 15:03

Darko Petreski


People also ask

What is merging in svn?

In Subversion terminology, the general act of replicating changes from one branch to another is called merging, and it is performed using various invocations of the svn merge subcommand. In the examples that follow, we're assuming that both your Subversion client and server are running Subversion 1.7 (or later).

Does svn merge delete the branch?

If you merge a branch into trunk using "svn merge --reintegrate", you are recommended to delete the branch. If you want to do further development in that branch, you should "re-branch", effectively create a new branch with the same name, but rooted at the same revision as you merged the branch into trunk.

How do I create a merge request in svn?

To add a new merge request, simply go to the Merge Requests sub-tab of your desired SVN repository. Then, select the New Merge Request button to the right of the screen. From there, the source branch can be selected from the From dropdown menu. The target branch can also be selected under To.


1 Answers

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.

like image 85
Sander Rijken Avatar answered Nov 05 '22 02:11

Sander Rijken