重命名SVN存储库项目名称
我已经将一个项目从 CVS 迁移到 SVN。现在我需要重命名该项目。重命名它、保持所有历史完整的最佳方法是什么?项目文件夹包含大约 100 个 C 代码及其头文件。
I have migrated a project from CVS to SVN. Now I need to rename that project. What can be the best possible way to rename it, keeping the all the history intact. The project folder contains some 100 numbers of C and its header files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
为了重命名存储库,您只需重命名其根目录并生成新的 UUID。假设存储库位于
/var/svnroot/my_repo
中,您必须运行此命令(以 root 身份)来重命名存储库:之后,您可以通过您喜欢的协议访问它。
In order to rename a repository you only have to rename its root directory and generate a new UUID. Assuming the repository is in
/var/svnroot/my_repo
you have to run this commands (as root) to rename a repository:After that, you can access it through your favorite protocol.
原始答案(已被接受)在提出问题时与原始问题(此后也已被编辑)相关。
事情已经发生了变化,正如其他人在此线程中指出的那样,现在有更好的方法来重命名存储库和/或存储库内的项目。
我已将此答案转换为社区维基,以便其他人继续维护它并确保它保持相关性。所以不会让我删除答案,因为它已被接受,并且您无法删除并接受答案。
The original answer (which got accepted) was relevant at the time the question was asked, for the original questions (which has since been edited as well).
Things have changed and as others have pointed out in this thread, there are now better ways to rename repositories and/or projects inside a repository.
I've converted this answer to a community wiki to let others maintain it forward and ensure it stays relevant. SO won't let me delete the answer because it was accepted and you can't delete and accepted answer.
SVN 书籍 \ 5. 存储库管理 \ 移动和删除存储库:
重命名通常在同一服务器上完成,因此只需对存储库目录进行简单的重命名/移动即可完成。
svnadmin setuuid
的调用不需要,因为您没有制作副本并且 UUID 应保持不变,以便您的客户端可以轻松地重新定位到新的存储库 URL。SVN Book \ 5. Repository Administration \ Moving and Removing Repositories:
Rename is typical done on the same server, so a simple rename/move of the repository directory will do it. The call of
svnadmin setuuid
is not required, because you are not making a copy and the UUIDs should stay the same, so your client can easily relocate to the new repository URL.SVN 1.1(旧书):
有时管理员可能会更改存储库的“基本位置”,换句话说,存储库的内容不会更改,但用于访问存储库根目录的主 URL 会更改。例如,主机名、URL 方案或指向存储库本身的 URL 的任何部分可能会更改。您可以使用 svn switch 命令“重写”工作副本中所有 URL 的开头,而不是签出新的工作副本。使用 --relocate 选项进行替换。没有更改文件内容,也没有联系存储库。这类似于在工作副本 .svn/ 目录上运行 Perl 脚本,该目录运行 s/OldRoot/NewRoot/。
SVN 1.7(当前book):
svn relocate — 重新定位工作副本以指向不同的存储库根 URL。
概要
svn relocate FROM-PREFIX TO-PREFIX [PATH...]
svn relocate TO-URL [PATH]
说明
,管理员可能会更改存储库的位置(或从客户端的角度来看,明显的位置)。存储库的内容不会更改,但存储库的根 URL 会更改。主机名可能会更改,因为存储库现在由另一台计算机提供服务。或者,URL 方案可能会发生变化,因为存储库现在通过 SSL(使用 https://)而不是通过纯 HTTP 提供服务。这些类型的存储库迁移有许多不同的原因。但理想情况下,存储库的“地址更改”不应突然导致指向该存储库的所有工作副本永远无法使用。幸运的是,事实并非如此。 Subversion 提供了 svn relocate 命令,该命令“重写”工作副本的管理元数据以引用新的存储库位置,而不是在存储库重新定位时强制用户签出新的工作副本。
第一个 svn relocate 语法允许您更新一个或多个工作副本,其实质上相当于在这些工作副本中记录的存储库根 URL 中进行查找和替换。 Subversion 会将这些 URL 中的初始子字符串 FROM-PREFIX 替换为字符串 TO-PREFIX。这些初始 URL 子字符串可长可短,以区分它们。显然,要使用此语法形式,您需要知道工作副本指向的存储库的当前根 URL 以及该存储库的新 URL。 (您可以使用 svn info 来确定前者。)
第二种语法不需要您知道与工作副本关联的当前存储库根 URL — 只需知道它应该关联的新存储库 URL (TO-URL)指点一下。在这种语法形式中,一次只能重定位一个工作副本。
示例
让我们从反映本地存储库 URL 的工作副本开始:
有一天,管理员决定重命名磁盘存储库目录。我们错过了备忘录,因此下次尝试更新工作副本时会看到错误。
在自动售货机逼迫管理员后,我们了解到存储库已被移动,并被告知新的 URL。不过,我们只是要求 Subversion 重写工作副本元数据以指向新的存储库位置,而不是签出新的工作副本。
Subversion 并没有告诉我们太多关于它做了什么,但是嘿——无错误操作确实是我们所需要的,对吧?我们的工作副本再次可用于在线操作。
默认情况下,svn relocate 将遍历工作副本中嵌套的任何外部工作副本,并尝试重新定位这些工作副本。使用
--ignore-externals
选项禁用此行为。SVN 1.1 (old book):
Sometimes an administrator might change the “base location” of your repository—in other words, the contents of the repository doesn't change, but the main URL used to reach the root of the repository does. For example, the hostname may change, the URL scheme, or any part of the URL which leads to the repository itself. Rather than checkout a new working copy, you can have the svn switch command “rewrite” the beginnings of all the URLs in your working copy. Use the --relocate option to do the substitution. No file contents are changed, nor is the repository contacted. It's similar to running a Perl script over your working copy .svn/ directories which runs s/OldRoot/NewRoot/.
SVN 1.7 (current book):
svn relocate — Relocate the working copy to point to a different repository root URL.
Synopsis
svn relocate FROM-PREFIX TO-PREFIX [PATH...]
svn relocate TO-URL [PATH]
Description
Sometimes an administrator might change the location (or apparent location, from the client's perspective) of a repository. The content of the repository doesn't change, but the repository's root URL does. The hostname may change because the repository is now being served from a different computer. Or, perhaps the URL scheme changes because the repository is now being served via SSL (using https://) instead of over plain HTTP. There are many different reasons for these types of repository relocations. But ideally, a “change of address” for a repository shouldn't suddently cause all the working copies which point to that repository to become forever unusable. And fortunately, that's not the case. Rather than force users to check out a new working copy when a repository is relocated, Subversion provides the svn relocate command, which “rewrites” the working copy's administrative metadata to refer to the new repository location.
The first svn relocate syntax allows you to update one or more working copies by what essentially amounts to a find-and-replace within the repository root URLs recorded in those working copies. Subversion will replace the initial substring FROM-PREFIX with the string TO-PREFIX in those URLs. These initial URL substrings can be as long or as short as is necessary to differentiate between them. Obviously, to use this syntax form, you need to know both the current root URL of the repository to which the working copy is pointing, and the new URL of that repository. (You can use svn info to determine the former.)
The second syntax does not require that you know the current repository root URL with which the working copy is associated at all—only the new repository URL (TO-URL) to which it should be pointing. In this syntax form, only one working copy may be relocated at a time.
Examples
Let's start with a working copy that reflects a local repository URL:
One day the administrator decides to rename the on-disk repository directory. We missed the memo, so we see an error the next time we try to update our working copy.
After cornering the administrator over by the vending machines, we learn about the repository being moved and are told the new URL. Rather than checkout a new working copy, though, we simply ask Subversion to rewrite the working copy metadata to point to the new repository location.
Subversion doesn't tell us much about what it did, but hey—error-free operation is really all we need, right? Our working copy is functional for online operations again.
By default, svn relocate will traverse any external working copies nested within your working copy and attempt relocation of those working copies, too. Use the
--ignore-externals
option to disable this behavior.首先了解
\Repositories
文件夹所在的位置(默认C:\Repositories
)之后,在
/Repositories
文件夹内重命名您想要的存储库。 (windows)如果您使用 eclipse,则放弃 SVN 存储库中的旧存储库位置并转到
New->Repository Location...->;您的新存储库名称
。就是这样。First get to know where the
\Repositories
folder residing at, (defautC:\Repositories
)After that rename your repository you want to, inside that
/Repositories
folder. (windows)If you are using eclipse then discard the old repository location in SVN Repositories and goto
New->Repository Location...-> your new repository name
. Thats it.