svn: replace trunk with branch

后端 未结 8 1867
自闭症患者
自闭症患者 2020-12-07 07:02

What is the best way to make one of the branches of a subversion repository the new trunk?

There has been a major rewrite for the entire system: t

相关标签:
8条回答
  • 2020-12-07 07:43

    I was just looking at this problem recently, and the solution that I was very happy with was performing

    svn merge --ignore-ancestry trunk-url branch-url

    on the working copy of my trunk.

    This does not try to apply changes in a historical manner (maintaining changes in the trunk). It simply "applies the diff" between the trunk and the branch. This will not create any conflicts for your users in the files that were not modified. You will however lose your Historical information from the branch, but that happens when you peform a merge anyway.

    0 讨论(0)
  • 2020-12-07 07:47

    While the answers above will work, they aren't best practice. The latest svn server and client track merges for you. So svn knows which revisions you've merged into a branch and from where. This helps a lot when keeping a branch up-to-date and then merging it back into the trunk.

    No matter which version of Subversion you're using however, there is a best practice method for getting changes in a branch back into trunk. It is outlined in the Subversion manual: Version Control with Subversion, Chapter 4. Branching and Merging, Keeping a Branch in Sync.

    0 讨论(0)
  • 2020-12-07 07:48

    It is a really weird/unusual configuration in SVN, even I think it is far from being a "good practice" at all, anyway, I guess you could do something like:

    • Checkout all the sourcetree (svn co therootsourcetree)
    • Remove the trunk (svn rm trunk)
    • Copy the branch to the trunk (svn cp branches/thebranch /trunk)
    • Remove the branch (svn rm branches/thebranch)
    • Commit the changes

    Good luck

    0 讨论(0)
  • 2020-12-07 07:49

    I agree with using the svn move command to accomplish this goal.

    I know others here think its unusual, but I like to do it this way. When I have a feature branch and am ready to merge it with a trunk that has also be significantly modified, I will merge it to a new branch, usually named <FeatureBranchName>-Merged. Then I resolve conflicts and test the merged code. Once that's complete I move the trunk to the tags folder so I don't lose anything. Lastly I move my <FeatureBranchName>-Merged to the trunk.

    In addition I prefer to avoid the working copy when doing the moves, here are samples of the commands:

    svn move https://SVNUrl/svn/Repo/trunk https://SVNUrl/svn/Repo/tags/AnyName
    
    svn move https://SVNUrl/svn/Repo/branches/BranchName-Merged https://SVNUrl/svn/Repo/trunk
    

    Note: I use 1.5

    0 讨论(0)
  • 2020-12-07 07:51

    Use svn move to move the contents of the old trunk somewhere else and rename the branch to trunk afterward.

    Note that copy and move in svn work like file operations. You can use them to move/copy stuff around in your repository and these changes are versioned as well. Think of "move" as "copy+delete".

    [EDIT] Nilbus just notified me that you will get merge conflicts when you use svn move.

    I still think that this is the correct approach. It will cause conflicts but if you merge carefully, chances are that you won't lose any data. If that bothers you, use a better VCS like Mercurial or Git.

    0 讨论(0)
  • 2020-12-07 07:51

    Recommend you do these changes via the repository browser tool.

    Attempting large delete+move operations via the working copy is a great way to kill the working copy. If you are forced to use the working copy, perform incremental commits after each delete or move operation and UPDATE your working copy after each commit.

    0 讨论(0)
提交回复
热议问题