SVN strategy using branches, and merging changes from trunk into branch
Asked Answered
N

1

19

So long time user of SVN, but fairly inexperienced in branching / tagging, and when I have I suspect I'm not really using it correctly or to its full potential.

I have my trunk which I work on adding new features etc. This code base is used in multiple websites, where we create a branch off the trunk on a per project basis.

Each branch usually has modifications specific to that project, and anything we think will be re-usable is added to the trunk, and made so that feature can be toggled on and off on the various projects.

Currently when we make changes to the trunk, and want those modifications in a pre-dated branch, I have to go through and manually merge certain revisions into the branch and recommit them. Not ideal, and easy to miss stuff.

So, my question... is there any way to update my branch with ALL of the changes from the trunk, and deal with them as if it was a standard trunk update with conflicts?

I have seen about reintegrating the branch to the trunk, but due to the way I am using branches in this instance, thats not really something I want to do.

Nobile answered 21/3, 2013 at 11:52 Comment(6)
Do you use svn from the command line or do you use a gui like TortoiseSVN?Kraus
So, I have been a SVN user for pretty much as long as it's been around. And though you can fight with SVN to make it do some of what you want, I have to be honest: git is much much better at this. It's designed around exactly what you're talking about (but think "even more branches"). If you want to do lots of branch merging and tracking of things, I'd convert your SVN repo to a git repo and go from there. You'll be happier (I know I am much more confident in knowing my patches are applied everywhere after having converted a 10+ year SVN project to git)Senzer
I use a combination of smartsvn (probably more this), and command lineNobile
And interesting, I had looked at git briefly, but it seemed over complicated when I looked at it before, although I now use svn for this project + branch setup so usage has evolved somewhat. Will give it another lookNobile
@WesHardaker in the end I actually moved over to git, you were right, its a lot better. hardly use SVN anymore except for real legacy projectsNobile
@Nobile Welcome to the distributed club! ha ha! Good choice!Senzer
W
22

Yes it is possible. Basically, you need to run svn merge from a clean working copy of your branch (one with no local modifications):

$ pwd
/home/user/mybranch
$ svn status # Does not display anything
$ svn update # Make sure your local copy is up to date.
Updating '.':
At revision X.
$ svn merge url/to/repository/trunk
Updates, additions, deletions and conflicts.
$ #handle conflicts.
$ svn commit -m "Merging changes from the trunk".

See Keeping a Branch in Sync from the SVN book.

The first merge is likely to introduce many conflicts, especially if the branch forked a long time ago, but latter merges will go smoothly, especially if you merge often.

Whirligig answered 23/3, 2013 at 14:51 Comment(1)
I did that and after, when I tried to update the trunk from the brach, all the new classes updated from the truck were in conflict. Did I do something wrong? Or do it has to happen this way?Heritor

© 2022 - 2024 — McMap. All rights reserved.