I always have to look up the documentation on how to merge a whole SVN branch to another. Today there were bug fixes to trunk of my project that I wanted to port into my branch. I expected this to be easy since I hadn’t made many changes to my branch, and no changes to the same files that were modified in the trunk.
Using Common Use-Cases as a reference, this is what I did:
From within my branch:
svn log |
This displays the revision number for when my branch was created:
------------------------------------------------------------------------ r23 | stereosv | 2009-02-17 11:42:28 -0500 (Tue, 17 Feb 2009) | 1 line creating branch for xyz |
Now I need to find out what revision number the trunk is at. Perfoming an “svn update” within the trunk shows me what version it’s at.
> svn update At revision 25. |
In my case the trunk is at revision 25… implying there were only two commits since the time I checked out my branch. Nice.
Now, it’s time to carry merge these changes into my branch. Back in my branch directory, it’s time to put these revision numbers to good use.
svn merge -r 23:25 svn+ssh://username@svnserver/home/username/svn/project/trunk |
What this does is merge the changes that were made between revision 23 (when I created my branch) and revision 25 (the most recent revision of the trunk) in the trunk into my working copy.
Now, it’s time to check in my branch, with the updated changes from the trunk.
svn ci -m "Merged trunk changes r23:25 into my branch" |
SVN 1.5 has made some improvements to the way merging works.. So check your SVN version with “svn –version” to make sure you are using the right syntax for your version.


I’m a command-line junky myself, but I find SVN almost too obnoxious (overhead-wise) to do from the CLI. I suggest you check out Versions or Cornerstone. Both are excellent. For diff, you can always use FileMerge if you have the Apple Developer Tools installed, or something like Changes or Araxis Merge. I personally prefer Changes.
The merge predicament is a common one, so I look it up too almost every time I use it. However, I’ve adopted a work flow that dodges around it: rather than merging the trunk with my branch, I will simply update the working copy and diff the changes if necessary. Fortunately though, I work with basically no one, so I don’t have a big problem with this.
Thanks for your work!
–
Piotr
Thanks, this was really helpful!
Pingback: Updating branch with changes from trunk. « Talueee's Blog
Thanks for share.
I was able to use this nicely.
Thanks for the write-up.
Nice. I use ‘svn log -l 1′ so i just get the last revision.
Thanks!
Thanks.very helpful
Pingback: Subversion: merging updates in trunk to a branch – Lennart's weblog