How to replace a branch in subversion?

2019-06-08 00:16发布

问题:

I'v never used branching till yesterday so I didn't knew that I should make the branch our of the trunk. So I branched a subfolder and this caused some side effects like accidental switching the trunk to branch ... this resulted in overwriting the trunk with the subfolder and deleting everything else inside the trunk = destroying my working copy ;/

Now I'm in the situation that I want to override this problematic branch with my working copy. How can this be performed? I'm using Tortoise SVN.

回答1:

It's easily possible via commandline:
You can switch your working copy back to trunk with svn switch TrunkURL in your local repo.

Use svn remove URL to remove the branch, you then can recreate the branch with the right source. With svn switch branchURL you can switch your local copy to the newly created branch.

With TortoiseSVN:

  • Rightclick on your repo, go into the Tortoise-menu and select Switch. Select your trunk, you will then have your local repo back to trunk.
  • Go into the Tortoise SVN Repo browser, there locate your branch. Right click on it and remove it
  • Recreate the branch by rightclicking your trunk and selecting Copy to...
  • Switch your local repo with the switch command from the first point. This time just select the branch instead of trunk.

No worries, you won't lose any files stored in the SVN. Even your first branching-experiment will stay in there at a certain Revision.