SVN Merge – Merging a Branch Into the Trunk

So you’ve created a branch for one reason or another, mainly to make sure that the trunk stays stable and doesn’t create chaos for the other developers on your team. You’ve committed several changes to this branch and thoroughly tested them to make sure everything is in working order. Now how do you get them back into the trunk? This is how.

You should have a local copy of the branch since that is where you have done the development.


Now, if you don’t already have a copy of the trunk locally, get one. Navigate to your local copy of the trunk.


You will need the revision number of the revision when you created the branch. For the sake of this example, I will say that the branch was at revision 100. Now run the following command to merge the branch into your local copy of the trunk.

svn merge -r 100:HEAD

You should now see that the files modified in your branch have been merged in your local copy of the trunk. Some files may be in conflict, and will have a “C” next to them in the file list after the merge command was run. You can also run an svn status to see if any files are in conflict. Resolve all conflicts, manually if necessary. Now make sure everything is working on your local copy of the trunk. If so, check your changes into the trunk.

On a side note, I like to tag the trunk before I merge a branch back into it. It just puts my mind at ease knowing I have a snapshot of a known working copy of the trunk.