I am new to SVN. I found when you merge branch A to branch B, SVN moves all content in branch A to B, not copy. And when you copy branch A to branch C and when you do the same thing again, it gave you an error branch C already exists.
What I want to accomplish is:
branch/dev
– for developmentbranch/dev
to branch/test
– for function testbranch/test
to trunk
– for stageSince I cannot override the existing branch, when I want to copy branch/dev
again, I need to delete test first, which is inconvenient.
Is there a way to do it?
If you copy from /a
to /b
, when /b
already exists, you end up with /b/a
.
If you want the equivalent of copy-with-overwrite, you will have to do a delete and then a copy, like this:
svn delete https://myserver/myrepo/branch/test -m "Removing test prior to copy"
svn copy https://myserver/myrepo/branch/dev -r HEAD
https://myserver/myrepo/branch/test
--parents -m "Copying dev branch to test"
When users in the test branch do an svn update
, svn is smart enough to only download the changed files, rather than re-downloading the entire project.
The downside with this approach is that there is some time, even if it is only for a few seconds, where that branch won't exist, and users already in that branch will get an error if they try to update.
svn merge
does not "move all content". In fact, "merging" and "copying" is in Subversion to very different operations. Merging will take the changes made in a branch and merge them into a working copy:
$ cd my/working/copy
$ svn merge ^/branches/myfeaturebranch .
Will merge all (unmerged) changes from ^/branches/myfeaturebranch
into my/working/copy
. This will leave you with a working copy containing all the changes from /branches/myfeaturebranch
which you are attempting to merge. At this point you may also have conflicts which you need to resolve before committing. (Note that the final act of merging is simply committing a bunch of changes.)
Copying, on the other hand, is like cp -r SRC DST
, where SRC
and DST
may either be local filesystem paths or repository URLs. When doing a repo-to-repo copy, Subversion will copy (not merge) all changes from SRC
to DST
. For example:
$ svn copy ^/trunk ^/tags/1.0.0
This will copy (or "tag") the current trunk to ^/tags/1.0.0
. If the destination already exists, Subversion will refuse to overwrite it.
So, what you want to do is probably something like
$ svn copy ^/trunk ^/branches/dev # create dev branch from trunk
$ svn co ^/branches/dev # checkout dev branch
$ cd dev
$ .... hack away ....
$ svn commit .... # commit your development changes
$ svn copy ^/branches/dev/ ^/branches/test # create testing branch
$ svn switch ^/branches/test # switch to testing branch
$ .... perform tests ....
$ svn commit .... # commit your changes in the testing branch
$ svn switch ^/trunk # switch back to trunk
$ svn merge ^/branches/test . # merge testing changes into working copy for trunk
$ .... resolve any conflicts ....
$ svn commit .... # commit merge
$ svn copy ^/trunk ^/tags/1.0.0 # final production tag
Hope this straightens out things a little.
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