我们正在尝试使用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
Run Code Online (Sandbox Code Playgroud)
PS我的SVN repo URL也是正确的,它位于主干上方.我在Win7 64位机器上尝试这个.
谢谢!
Ser*_*nov 10
迟到了,但有人可能还需要这个.我设法跟踪问题#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
Run Code Online (Sandbox Code Playgroud)
注意有没有引号#{trunk},#{tag}和#{branch}更多.这就是诀窍.
有很多名为 的工具,最好的可能是来自https://github.com/svn-all-fast-export/svn2gitsvn2git的 KDE 工具。我强烈建议使用该工具。这是我所知道的最好的,并且它的规则文件非常灵活。svn2git
您使用的工具svn2git基于存储库或存储库部件的一次性转换,git-svn但git-svn并不是正确的工具。如果您想使用 Git 作为现有 SVN 服务器的前端,那么它是一个很棒的工具,但对于一次性转换,您不应该使用,git-svn但svn2git它更适合此用例。
如果您不是 100% 了解存储库的历史记录,svnevereverhttp ://blog.hartwork.org/?p =763 是一个很好的工具,可以在将 SVN 存储库迁移到 Git 时调查其历史记录。
尽管git-svn(或者在您的情况下是错误的svn2git)更容易开始,但除了它的灵活性之外,以下是使用 KDEsvn2git而不是更优越的一些进一步原因:git-svn
svn2git(如果使用了正确的历史记录),对于具有分支和合并等的更复杂的历史记录尤其如此git-svn一个额外的空提交,这也使得它们不属于分支的一部分,因此在您向命令fetch提供之前,普通不会获取它们,因为默认情况下,也只获取指向所获取分支的标签。--tags有了正确的 svn2git 标签,它们就在它们所属的地方svn2git,git-svn最终您将丢失历史记录svn2git可以轻松地将一个 SVN 存储库拆分为多个 Git 存储库svn2git使用正确的转换比使用正确的转换快数亿倍git-svn有很多原因可以解释为何git-svnKDE 更差而 KDEsvn2git更优越。:-)