Skip to main content

SVN: Merge a branch with your trunk

·229 words·2 mins· ·
General Everything Features Subversion
Ariejan de Vroom
Author
Ariejan de Vroom
Jack of all Trades, Professional Software Craftsman

When created a TRY-branch a few days back to try some fancy new AJAX technology in my application. Not problems there, so now I want to merge the code in the branch with my trunk.

Since I’m a lone hacker, the trunk has not been touched since I created the branch. I have a checked-out working copy of the branch available.

Here’s a handy-dandy guide on how to merge your branch code with your trunk.

Firstly, make sure you have a working copy of your trunk. I choose to switch my working copy back: (oh, make sure you have all your changes checked in in your branch before you switch!)

$ svn switch http://example.com/svn/myproject/trunk

This removes, adds and updates all files you have worked on in your branch and creates a working copy of the code in the trunk.

Now, with my trunk in place, I can call ‘merge’ and apply the changes.

$ svn merge http://example.com/svn/myproject/trunk http://example.com/svn/myproject/branches/TRY-AJAX

Since the files from the trunk and the beginning of the TRY-branch are still exact copies, I won’t get in any trouble. If you do (and you did change your code in your trunk), make sure to resolve merging problems before checking in. When ready, check in your new code!

$ svn ci -m "Merge TRY-AJAX branch with trunk"

That’s it. You have now merged the branch with your trunk. Enjoy!

Related

SVN: How often should you commit?
·448 words·3 mins
General Everything Features Subversion
Show the current SVN revision in your Rails app
·284 words·2 mins
General Everything RubyOnRails Features Subversion Capistrano
How to setup a Ubuntu development server - Part 1
·1254 words·6 mins
General Everything Web Development Features Ubuntu Subversion