Merge a branch with the trunk in Subversion

I restart my blog posting activity by sharing with you a little cookbook that may be useful if you use Subversion to manage your source code repository.

If you are using Subversion, you most likely have already created (or thinking of creating) branches to manage different versions of your source code.

When the time comes to merge my changes between branches or a branch and the trunk, I always forget the syntax, so here's a small step by step merge execution.

I am assuming you have checked out both the branch and trunk from your subversion repository. If you haven't done so, you can easily checkout with:

svn co <repository>

First of all, go to the branch main directory, and execute the following:

svn log --stop-on-copy

The last entry is the version number corresponding to the creation of the branch, and looks something like the following:

r2887 | daniel | 2008-03-25 12:20:52 +0100 (Tue, 25 Mar 2008) | 1 line
Creation of new branch for version 1.6. ------------------------------------------------------------------

So, we have found out that the version is 2887. Now, change directory to the trunk, and execute the following command:

svn up

The output of this command should be something like:

At revision 3117.

Basically, that means that we have to merge the changes from revision 2887 to 3117, using the following command:

svn merge -r2887:3117 https://<repository>/branches/<version>

Now, you should check the changes performed to your local copy, and resolve any change conflicts that may appear.

Once you have verified that the changes are correct, you can check in with the usual svn ci.



Trackback URL for this entry:

No trackback comments for this entry.


Post a comment


About is a blog about technology, opinion and random thoughts written by Daniel Alvarez, a computer engineer currently living in Zurich, Switzerland.


User Functions



Lost your password?

Latest posts

Stories last 24 hours

No new stories

Comments last 2 days

No new comments

Trackbacks last 2 days

No new trackback comments

Links last 2 weeks

No recent new links