SUBSCRIBE VIA RSS


Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.

Topics

TWITTER

Stack Overflow


The old fashioned way

RECENT TUNES

February 17, 2009 – 12:43pm SVN merge trunk changes to your branch

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.

Posted by in  Web Development   |  

9 Responses to SVN merge trunk changes to your branch

  1. Andrew Noyes says:

    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.

  2. Thanks for your work!


    Piotr

  3. Wayne Khan says:

    Thanks, this was really helpful! :)

  4. Pingback: Updating branch with changes from trunk. « Talueee's Blog

  5. Patrick says:

    Thanks for share. :)

  6. Aartist says:

    I was able to use this nicely.

    Thanks for the write-up.

  7. andres says:

    Nice. I use ‘svn log -l 1′ so i just get the last revision.

    Thanks!

  8. Ezhil says:

    Thanks.very helpful :)

  9. Pingback: Subversion: merging updates in trunk to a branch – Lennart's weblog

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>