Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing trunk with branch in Subversion

Tags:

svn

Let's say people have been working on the trunk and on a branch of a Subversion repository. I want to discard any changes on the trunk, and replace it with a copy of the branch.

As suggested in another question, I can just move or remove the trunk, and then copy the branch over to the trunk. But then the trunk's history is replaced with the branch's history. What if I want to retain the trunk's history?

I think what I want is something like a merge, but one where the destination's changes are ignored, and just replaced with the source. How would I do this in Subversion? Is this considered good practice?

like image 643
JW. Avatar asked Feb 25 '09 20:02

JW.


People also ask

How do I switch to a branch in svn?

When you svn switch your working copy to the branch, the local changes will remain. You can then test and commit them to the branch. You can , however, use svn switch with the --relocate switch if the URL of your server changes and you don't want to abandon an existing working copy.

What is the difference between trunk and branch in svn?

A trunk in SVN is main development area, where major development happens. A branch in SVN is sub development area where parallel development on different functionalities happens. After completion of a functionality, a branch is usually merged back into trunk.


2 Answers

Though its a pretty old thread but still sharing my experience

We recently did this for one of our projects and followed guidelines as:

svn copy <repos/trunk> <repos/tag/old_trunk> -m "copied old trunk as tag"  svn delete <repos/trunk> -m "deleted trunk temporarily"  svn copy <repos/branch/new_fetaure_branch> <repos/trunk> -m "placed new trunk with features" 

Following these steps kept the trunk history intact and replace the new feature branch as trunk.

like image 185
Bharat Sinha Avatar answered Sep 25 '22 13:09

Bharat Sinha


Pre-1.5 this is simple: make sure your working copy points to trunk, then do "svn merge url-of-trunk url-of-branch". The changes you receive are the delta between trunk and branch, effectively "give me everything that's needed to make trunk look like branch."

I have no idea if 1.5's new merge capabilities change this scenario.

like image 38
Rytmis Avatar answered Sep 22 '22 13:09

Rytmis