如何重命名SVN分支并更新现有沙箱中的引用?

如何重命名SVN分支并更新现有沙箱中的引用?,svn,branch,rename,Svn,Branch,Rename,我需要重命名一个SVN分支,所以我做到了: $ svn move https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch $svn移动https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch 到目前为止,一切都很好,该分支

我需要重命名一个SVN分支,所以我做到了:

$ svn move https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch $svn移动https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch 到目前为止,一切都很好,该分支已被重命名

问题是,我们已从该分支签出现有沙盒,当我尝试更新时,会出现以下错误:

$ svn update svn: Target path '/branches/oldbranch' does not exist $svn更新 svn:目标路径“/Branchs/oldbranch”不存在 一个相当不言自明的错误。快速搜索后,我认为我找到了解决方案:

问题是,当我试图发出该命令时,我会遇到另一个错误:

$ svn switch --relocate https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch svn: Relocate can only change the repository part of an URL $svn交换机--重新定位https://server/repos/myrepo/branches/oldbranch \ https://server/repos/myrepo/branches/newbranch svn:重新定位只能更改URL的存储库部分 就我所见,我使用的
--relocate
命令与Sander Rijken的方法相同。知道我为什么会犯这个错误吗

就这么做吧

svn switch https://server/repos/myrepo/branches/newbranch

从您的工作副本中。

要更改相对路径,您必须使用
svn开关
(无论如何
开关-重定位
是不推荐的),如
svn帮助开关
中针对第一种形式所述

切换URL[@PEGREV][PATH]
更新工作副本以镜像存储库中的新URL

 This behavior is similar to 'svn update', and is the way to
 move a working copy to a branch or tag within the same repository.
例如,在
oldbranch
的WC根目录中,现在是
newbranch
,您必须使用


svn-switch^/branchs/newbranch
如果您只是想在Eclipse中重命名一个svn分支,最简单的方法是进入svn存储库探索透视图,然后右键单击您的分支->重构->重命名

我不认为Sander Rijken的答案是正确的。我对他的回答添加了一条评论。谢谢,这很有效,但当我下次执行
svn更新时,它确实会从沙盒中删除所有未版本的文件。。。我希望避免的事情。
从您的工作副本中
=>您的意思是“
cd[oldbranch]
首先,从那里键入命令
svn开关[…]
?我知道@OlivierPons的问题已经问了7年了,但是因为没有人确认-为了这里未来的访问者,是的-你会做
cd oldbranch
,然后
svn switch^/Branchs/newbranch
(注意,^告诉svn你正在相对于当前分支的根路径进行切换。)