svn2git - 命令失败 - 错误:pathspec' master'与git已知的任何文件都不匹配

时间:2016-12-19 20:10:58

标签: git svn svn2git

我们正在尝试使用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  

P.S。我的SVN repo URL也是正确的,它位于主干上方。我在Win7 64位机器上尝试这个。

谢谢!

3 个答案:

答案 0 :(得分:9)

迟到了,但有人可能仍然需要这个。我设法将其追踪到issue #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
    end

请注意,#{trunk}#{tag}#{branch}周围没有引号。这就行了。

答案 1 :(得分:1)

有一些称为svn2git的简单工具,最好的工具是来自https://github.com/svn-all-fast-export/svn2git的KDE工具。我强烈建议您使用svn2git工具。这是我所知道的最好的,它可以非常灵活地使用它的规则文件。

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

如果您不是100%关于存储库的历史记录,那么http://blog.hartwork.org/?p=763中的svneverever是一个很好的工具,用于在将SVN存储库迁移到Git时调查其历史记录。

即使git-svn(或您的情况下的错误svn2git)更容易入手,以下是使用KDE svn2git代替git-svn的其他原因除了灵活性之外,它是优越的:

  • 历史由svn2git重建得更好更清洁(如果使用了正确的历史记录),对于更复杂的分支和合并历史记录来说尤其如此,等等
  • 标签是真正的标签,而不是Git中的分支
  • 使用git-svn标记包含一个额外的空提交,这也使它们不属于分支,因此正常fetch将不会获得它们,直到您将--tags作为命令提供给默认情况下,仅提取指向已获取分支的标记。正确的svn2git标签是他们所属的地方
  • 如果您在SVN中更改了布局,则可以使用svn2git轻松配置,git-svn最终会丢失历史记录
  • 使用svn2git您还可以轻松地将一个SVN存储库拆分为多个Git存储库
  • 或将同一SVN根目录中的多个SVN存储库轻松组合到一个Git存储库中
  • 使用正确svn2git比使用git-svn
  • ,转化速度快了数十倍

git-svn更糟糕且KDE svn2git优越的原因有很多。 : - )

答案 2 :(得分:0)

不是很多“答案”,但这是我的情况的解决方案。顺便说一句,来自svn2git的错误消息确实没有帮助。

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

SVN存储库具有如下结构:

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

我只用svn2git https://example.com/folderA --username ...来运行svn2git。

当我还在回购路径中包括“ / projectName”并执行此操作时:

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

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

相关问题