rc3.org

Since 1998.

rc3.org header image 1

Merging a branch back into the trunk in Subversion

November 17th, 2006 · 3 Comments

Let’s say you’ve got a project in a Subversion repository, and you’ve created a branch of trunk, in branches/newfeature. You’ve been merging changes from trunk to branches/newfeature for awhile, but now you’re done with that work and you’re ready to move all of the changes in the branch back to the trunk. What’s the best way to do this?

You can follow the directions in the Subversion book, but that leads to a huge number of conflicts. Is there a cleaner way? If you’ve merged everything from the trunk into the branch, then what you really need is to just move the latest stuff in the branch into the trunk, without worrying about conflicts at all.

3 responses so far ↓

  • 1 bo // Nov 17, 2006 at 11:26 am

    Assuming you’ve merged every revision from the trunk into the branch already, a merge of the differences between the trunk and the branch back to the trunk should work. In a clean working copy checked out from the trunk, do something like:

    svn merge hxxp://myrep.example.com/trunk hxxp://myrep.example.com/branches/newfeature .

    and then commit.

    Or you can do what I did when this came up, and just delete the trunk and copy the branch in its place.

  • 2 Andy Matthews // Jan 16, 2008 at 11:00 am

    But what if you have not been merging changes from the trunk into the branch? This is still new to me. I have a branch that’s about 2 months old which has has no updates either to, or from, the trunk.

    So I have many changes which need to be merged from the branch into the trunk. I’m using Subversion from within Eclipse.

  • 3 Rafe // Jan 16, 2008 at 11:29 am

    I would strongly recommend using the svnmerge script and initializing it at the point where you created the branch. Then you can use it to merge in both directions:

    http://www.orcaware.com/svn/wiki/Svnmerge.py

Leave a Comment

You can comment using OpenID:

Or you can just enter your personal information and comment that way. Your email address is required but won't be displayed.

Please enter your comment. Markdown is supported.