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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With