10

我们正在尝试使用 svn2git 实用程序(https://github.com/nirvdrum/svn2git)从 svn 迁移到 git。该实用程序似乎每次都失败并出现以下错误。如果有人看到相同的错误或有更好的选择,请分享。

命令
svn2git https://xyz.xyz.com/svn/svnrepo/ --verbose --authors authors.txt

控制台输出

Running command: git svn init --prefix=svn/ --no-metadata --trunk='trunk' --tags
='tags' --branches='branches' https://xyz.xyz.com/svn/svnrepo/  
Running command: git config --local --get user.name  
Running command: git config --local svn.authorsfile authors.txt  
Running command: git svn fetch  
Running command: git branch -l --no-color  
Running command: git branch -r --no-color  
Running command: git config --local --get user.name  
Running command: git config --local --get user.email  
Running command: git checkout -f master  
error: pathspec 'master' did not match any file(s) known to git.  
command failed:  
git checkout -f master  

PS 我的 SVN repo URL 也是正确的,它就在树干上方。我正在 Win7 64 位机器上尝试这个。

4

3 回答 3

25

晚了,但有人可能仍然需要这个。我设法将其追溯到问题 #241。长话短说,Windows 不理解脚本添加到命令'的参数周围的单引号 ( ) 。git可能有多种方法可以修复它,但我只是手动破解了该migration.rb文件,即以下代码段:

    cmd += "--trunk=#{trunk} " unless trunk.nil?
    unless tags.nil?
      # Fill default tags here so that they can be filtered later
      tags = ['tags'] if tags.empty?
      # Process default or user-supplied tags
      tags.each do |tag|
        cmd += "--tags=#{tag} "
      end
    end
    unless branches.nil?
      # Fill default branches here so that they can be filtered later
      branches = ['branches'] if branches.empty?
      # Process default or user-supplied branches
      branches.each do |branch|
        cmd += "--branches=#{branch} "
      end

请注意,周围没有引号#{trunk}#{tag}等等#{branch}。那成功了。

于 2018-03-18T15:41:11.297 回答
2

有很多称为svn2git的工具,可能最好的一个是来自https://github.com/svn-all-fast-export/svn2git的 KDE 工具。我强烈建议使用该svn2git工具。这是我所知道的最好的,并且在你可以用它的规则文件做什么方面非常灵活。

您使用的svn2git工具基于git-svn并且git-svn不是用于一次性转换存储库或存储库部分的正确工具如果您想使用 Git 作为现有 SVN 服务器的前端,这是一个很棒的工具,但对于一次性转换,您不应该使用git-svnsvn2git它更适合这个用例。

如果您不是 100% 了解存储库的历史,那么在将 SVN 存储库迁移到 Git 时,svnevereverhttp ://blog.hartwork.org/ ?p=763是一个很好的工具来调查 SVN 存储库的历史。


尽管git-svn(或在您的情况下是错误的)更容易开始,但除了灵活性之外,还有svn2git一些其他原因说明使用 KDEsvn2git而不是更优越的原因:git-svn

  • 历史被重建得更好,更清晰svn2git(如果使用正确的),尤其是对于具有分支和合并等的更复杂的历史
  • 标签是真正的标签,而不是 Git 中的分支
  • 标签包含git-svn一个额外的空提交,这也使它们不是分支的一部分,所以在fetch你给命令之前正常不会得到它们,--tags因为默认情况下只有指向已获取分支的标签也会被获取。使用正确的 svn2git 标签是它们所属的地方
  • 如果您更改了 SVN 中的布局,您可以轻松地配置它svn2gitgit-svn最终您将失去历史
  • 您还可以轻松地svn2git将一个 SVN 存储库拆分为多个 Git 存储库
  • 或轻松将同一个 SVN 根目录中的多个 SVN 存储库合并到一个 Git 存储库中
  • svn2git正确的转换比使用正确的要快无数倍git-svn

有很多原因导致git-svnKDE 更差,而 KDEsvn2git更胜一筹。:-)

于 2016-12-19T21:36:55.457 回答
1

没有太多的“答案”,但这是我的案例的解决方案。顺便说一句,来自 svn2git 的错误消息真的没有帮助。

我得到完全相同错误的原因是我在进行初始导入时没有使用主干的完整路径。

SVN repo 的结构如下:

https://example.com/folderA/projectName
 - trunk
 - tags
 - ...

我只用svn2git https://example.com/folderA --username ....

当我将“/projectName”也包含在回购路径中时,并这样做了:

svn2git https://example.com/folderA/projectName --username ...

...一切都很好。.git此外,在重试之前 - 我从以前的尝试中删除了现有文件夹。

于 2019-01-18T16:41:40.433 回答