【问题标题】:How to rename a repository in SVN?如何在 SVN 中重命名存储库?
【发布时间】:2013-03-04 08:04:45
【问题描述】:

我需要将现有的存储库根名称重命名为新名称。

我正在使用 svnserve 服务器。

URL: svn://somename.dev.loc.con.dept/export/svnrepo/**old_name/CL_abc/trunk
Repository Root: svn://somename.dev.loc.con.dept/export/svnrepo/**old_name
  1. 重命名 svn://somename.dev.loc.con.dept/export/svnrepo/old_name

    svn://somename.dev.loc.con.dept/export/svnrepo/new_name

  2. 在命令行中应该是:

    /export/svnrepo/**old_name**  to /export/svnrepo/**new_name** 
    
  3. 也需要重命名仓库名称

    CL_abc

    CL_newname

【问题讨论】:

标签: svn svnadmin svnserve svn-repository


【解决方案1】:

您需要在运行svnserve 命令的 Subversion 服务器上执行此操作。 svnserve 命令可以采用使用svnadmin create 命令创建的存储库的名称,也可以采用包含使用svnadmin 命令创建的多个存储库的目录。

一个存储库

$ hostname
$ mysvn
$ cd /opt/repos
$ svnadmin create foo
$ svnserve -r foo -d

访问该存储库

$ svn ls svn://mysvn
$ svn mkdir svn://mysvn/trunk svn://mysvn/tags svn://mysvn/branches
$ svn co svn://mysvn/trunk

在上面的示例中,我创建了一个名为 foo 的 Subversion 存储库,并以该存储库作为服务器的根运行 svnserve

当我访问该存储库时,URL 中没有存储库名称。我的 URL 的 root 只是机器名称。没有可重命名的内容。

多个存储库

$ hostname
$ mysvn
$ cd /opt/repos
$ svnadmin create foo
$ svnadmin create bar
$ svnserve -r . -d

访问这些存储库

$ svn ls svn://mysvn
svn: E210005: Unable to connect to a repository at URL 'svn://localhost'
svn: E210005: No repository found in 'svn://localhost'
$ svn ls svn://mysvn/foo
$ svn ls svn://mysvn/bar
$ svn mkdir svn://mysvn/bar/trunk svn://mysvn/bar/tags svn://mysvn/bar/branches
$ svn co svn://mysvn/bar/trunk

在本例中,我在/opt/repos 目录下创建了两个名为foobar 的Subversion 存储库目录。当我启动svnserve 时,我给它一个包含我的Subversion 存储库的目录的名称。我的存储库名称是我的目录的名称。我有目录foobar,这就是名字。如果我想更改存储库的名称,我需要在服务器上更改它们:

$ hostname
mysvn
$ pkill svnserve   #Stop the SVN server
$ cd /opt/repos
$ mv bar to fubar  #Change the repo name
$ svnserve -r /opt/repos -d

访问存储库

$ svn ls svn://mysvn/fubar/trunk

当我重新启动 SVN 服务器时,我的存储库有了一个新名称。

您似乎需要执行以下操作:

$ ssh somename.dev.loc.con.dept  #Get on the Subversion server
$ pkill svnserve                 #Shutdown the server
$ mv /export/svnrepo/oldname /export/svnrepo/newname
$ svnserve -r / -d

现在,您将能够使用新名称访问您的存储库。但是,我建议您通过以 /export/svnserve 为 root 启动 svnserve 进程来简化您的 Subversion URL:

$ svnserve -r /export/svnrepo -d

现在,用户可以使用略短的名称访问他们的项目:

$ svn co svn://somename.dev.loc.con.dept/newname/CL_abc/trunk

【讨论】:

  • 感谢大卫,感谢您的详细描述。我现在有点困惑。如果我在这里做错了什么,请告诉我 - 我只需要执行以下步骤 1. $ ssh somename.dev.loc.con.dept 2. $ pkill svnserve 3. $ mv /export/svnrepo/oldname /export /svnrepo/newname 4. $ svnserve -r / -d 5. $ svn co svn://somename.dev.loc.con.dept/newname/CL_abc/trunk
  • 那个。要使用svnserve 重命名存储库,您只需重命名该存储库的目录。我通常将-r 指定为存储库所在的目录或存储库目录本身。如果您以/ 作为存储库根目录启动 svnserve,我不知道该行为。此外,您现在必须从 svn URL 中的 /export 指定整个目录结构。
  • 谢谢,我会试试的。工作副本目录呢,我是否需要进行任何更改以反映新 URL?
  • 您需要使用svn relocate 或在旧的svn 客户端中使用svn switch --relocate。做svn help relocate.
  • 非常感谢大卫。这是完美的。
猜你喜欢
  • 2011-01-27
  • 2011-05-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-10
  • 2012-12-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多