如何使用git-svn切换svn存储库?

Ale*_*ing 21 svn git git-svn

我使用git-svn创建了许多作为SVN存储库克隆的git项目.我们已将SVN存储库迁移到新的提供程序,因此URL现已更改.如何更新git clone的远程SVN URL?

一种可能性是我从新的SVN存储库重新克隆,但我不想这样做,因为这个过程可能需要几天才能完成整个历史记录.

提出这个问题的另一种方法是,git在哪里存储有关您正在使用的远程SVN存储库位置的信息?即,当您输入'git svn info'时,URL信息来自哪里?

Ale*_*ing 24

我在git wiki中找到了一个页面,它正好回答了我的问题:

https://git.wiki.kernel.org/index.php/GitSvnSwitch

  • 编辑.git/config中的svn-remote url URL以指向新域名
  • 运行git svn fetch - 这需要从svn获取至少一个新版本!
  • 将svn-remote url更改回原始URL
  • 运行git svn rebase -l来执行本地rebase(包含上次提取操作带来的更改)
  • 将svn-remote url更改回新网址
  • 运行git svn rebase现在应该再次运行!

如果git svn fetch步骤实际上取任何东西,这只会起作用!(花了一些时间才发现......我不得不对我们的svn存储库进行虚拟修改以实现它!)


rye*_*nus 12

遵循相同的URL [1],但使用更新的解决方案,它变得更容易.

在里面.git/config,在该[svn-remote]部分中,设置url URL,并设置rewriteRoot URL:

[svn-remote "svn"]
    url         = https://new.svn-server.net/svn/root
    rewriteRoot = https://old.svn-server.net/svn/root
Run Code Online (Sandbox Code Playgroud)

同样可以通过git config ...指南中的命令完成:

$ git config --local --replace-all svn-remote.<name>.rewriteRoot `git config --local --get svn-remote.<name>.url`
$ git config --local --replace-all svn-remote.<name>.url <new_url>
Run Code Online (Sandbox Code Playgroud)

然后它只是工作,对我来说,即使新服务器上没有新的修订,我也不必进行任何虚拟修订.有趣的是,git svn info报告相同的旧URL,但使用新URL作为存储库根:

$ git svn info
Path: .
URL: <old-url>
Repository Root: <new-url>
Run Code Online (Sandbox Code Playgroud)

[1] https://git.wiki.kernel.org/index.php/GitSvnSwitch