Home > Features, General > SVN: Merge a branch with your trunk

SVN: Merge a branch with your trunk

December 20th, 2006

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!

Please share the love of this post by bookmarking it, and sharing it with others. Thanks!

  • Digg
  • del.icio.us
  • description
  • Reddit
  • Facebook
  • E-mail this story to a friend!
  • TwitThis

,

  1. December 20th, 2006 at 14:41 | #1

    You’re doing a great job with these SVN tutorials! Please keep it coming :)

  2. December 20th, 2006 at 15:35 | #2

    Thanks. I’m working on it :)

  3. Tim
    January 11th, 2007 at 17:12 | #3

    how to fix:
    svn: Aborting commit: ‘/path/file’ remains in conflict

    i made manual changes but it won’t commit

  4. Tim
    January 11th, 2007 at 17:17 | #4

    fixed..

    by removing the file.merge-left.rXX files in the same dir

  5. January 12th, 2007 at 13:03 | #5

    @Tim: You probably had some merging conflict that Subversion couldn’t figure out for itself. First run svn update and modify the file manually to merge changes manually. Next you should be able to complete the commit.

  6. marc
    June 23rd, 2008 at 16:27 | #6

    thanks mate!
    so useful!

  1. No trackbacks yet.