Svn Merge from Trunk to Branch

Every time I need to do this I try to use svn's --help which is only possible to decipher if you already know what to do. Then I spend too much time on the internet looking for the answer. And finally I break down and ask my tech lead. With much shame. I'm putting this up here so I least I'll know where to find it. Maybe you too.

In the directory of the branch:

svn merge -r 1001:1002 .

If you checked in some files in revision 1002, then what you're saying is that you only want the changes from that checkin with '-r 1001:1002' Which is followed by the url of the trunk (where the changes were checked in) and a '.' to say that you want to merge to the current directory. Use '--dry-run' if you want to see what would happen without actually screwing anything up. After the merge is successful, you now have some modified files in the branch you can check in.

Done and done.


Josh said…
Until SVN 1.5 is released ( you might want to use (

I'm not sure how I ever lived without a tool like this for managing branches.
JH said…
I've found that merging more than 10 revisions to be problematic for the merge process.

Here's a nugget if you are merging from a revision number to the current version:
svn merge -r 1001:HEAD .
Paul said…
You can also use a working copy instead of the URL, which can be easier:

svn merge -r 1001:1002 ../path/to/trunk .
Anonymous said…
exactly what i was looking for. fantastic!
Jeremy said…
I've gone back to this post over and over the past 6 months, so thanks!
Ravi said…
what if I need to pickup a couple of revisions at a time from the trunk and merge in the changes to my branch? Will this work:

svn merge -r 1001:1005 ../path/to/trunk .

Anonymous said…
It's 2012 now. Still done and done. Thanks.
Dave said…
Just what I needed — saved me a lot of pain.

Cheers Jake!
dhs said…
Still use this as a reminder every time I merge. Thanks.
Anonymous said…
Wonderful! Thanks - You just saved tons of hours of internet look-up (and the same type embarrassment you mentioned) for me.

Popular posts from this blog

What's a Good Flog Score?

SICP Wasn’t Written for You

Point Inside a Polygon in Ruby