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 in  Web Development   |     |  delicious  Digg

6 Responses to “SVN merge trunk changes to your branch”

  1. 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.

    By Andrew Noyes on Apr 21, 2009

  2. Thanks for your work!


    Piotr

    By ITtuition.com on May 14, 2010

  3. Thanks, this was really helpful! :)

    By Wayne Khan on Aug 27, 2010

  4. Thanks for share. :)

    By Patrick on Jun 29, 2011

  5. I was able to use this nicely.

    Thanks for the write-up.

    By Aartist on Oct 26, 2011

1 Trackback(s)

  1. Jan 21, 2011: Updating branch with changes from trunk. « Talueee's Blog

Post a Comment

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word