rc3.org

Strong opinions, weakly held

Merging a branch back into the trunk in Subversion

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 Comments

  1. 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. 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. 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 Reply

Your email address will not be published.

*

© 2024 rc3.org

Theme by Anders NorenUp ↑