33

我正在尝试使用git svn将 SVN 存储库克隆到 Git 中。

我运行以下命令:

C:\Projects>git svn clone -T trunk -b 分支 -t 标签 --no-metadata https://svn.mycompany.com/Projects/MyProject MyProject

我收到以下错误:

找到可能的分支点: https://svn.mycompany.com/Projects/MyProject/trunk => https://svn.mycompany.com/Projects/MyProject/tags/11.1.9.33334 , 33334

在 /usr/lib/perl5/site_perl/Git/SVN.pm 第 106 行使用未初始化值替换 (s///)。

在 /usr/lib/perl5/site_perl/Git/SVN.pm 第 106.refs/remotes/MyProject-10.2 行的连接 (.) 或字符串中使用未初始化的值:' https://svn.mycompany.com/Projects '在''中找不到

git的版本是:

1.8.1.msysgit.1

4

3 回答 3

72

我的问题是,由于 SVN(文件和日志)如此庞大,它在某些时候一直崩溃,当我重新启动它时,它在我的 .git/config 文件中创建了多行分支和标签。

branches = branches/*:refs/remotes/svn/branches/*
tags = tags/*:refs/remotes/svn/tags/*

我只是删除了这些重复的条目并使用我的命令重新启动

git svn fetch
于 2013-05-07T16:30:32.547 回答
1

我有同样的错误并通过升级到解决它git version 2.6.2.windows.1

于 2015-10-28T11:34:57.793 回答
0

同样的错误。我正在将我的 SVN 存储库转换为 Git。

git version 2.8.2.windows.1
Windows 8.1 Pro 64bits, running Git For Windows 32bits.

v1,trunk地址错误,误设置为和repository root一样:

C:\Windows\system32>git svn clone https://mycompany.svn.beanstalkapp.com/myproject 
        --no-metadata -A c:\temp\svn_to_git_users.txt 
        --trunk=https://mycompany.svn.beanstalkapp.com/myproject 
        --tags=https://mycompany.svn.beanstalkapp.com/myproject/tags 
        --branches=https://mycompany.svn.beanstalkapp.com/myproject/branches
        c:\code\Git_myproject

[...]
W: +empty_dir: branches/20080918_DBDEPLOY/vendor/src/csharp/MS WCSF Contrib/src/Services
W: +empty_dir: branches/20080918_DBDEPLOY/vendor/src/csharp/RealWorldControls/References
r530 = c276e3b039d8e38759c6fb17443349732552d7a2 (refs/remotes/origin/trunk)
Found possible branch point: https://mycompany.svn.beanstalkapp.com/myproject/trunk => https://mycompany.svn.beanstalkapp.com/myproject/branches/20080918_DBDEPLOY, 529
Use of uninitialized value $u in substitution (s///) at /mingw32/share/perl5/site_perl/Git/SVN.pm line 101.
Use of uninitialized value $u in concatenation (.) or string at /mingw32/share/perl5/site_perl/Git/SVN.pm line 101.
refs/remotes/origin/trunk: 'https://mycompany.svn.beanstalkapp.com/myproject' not found in ''

C:\Windows\system32>

v2 有效:更正了路径(并使用相对而不是绝对来缩短行)

C:\Windows\system32>git svn clone https://mycompany.svn.beanstalkapp.com/myproject 
        --no-metadata -A c:\temp\svn_to_git_users.txt --trunk=trunk 
        --tags=tags --branches=branches c:\code\Git_myproject
[...]
r529 = 40442d32486f4ca6f713e659b3785a446bd19de6 (refs/remotes/origin/trunk)
Found possible branch point: https://mycompany.svn.beanstalkapp.com/myproject/trunk => https://mycompany.svn.beanstalkapp.com/myproject/branches/20080918_DBDEPLOY, 529
Found branch parent: (refs/remotes/origin/20080918_DBDEPLOY) 40442d32486f4ca6f713e659b3785a446bd19de6
Following parent with do_switch
Successfully followed parent
r530 = 9fefc1b3a892555e315d55c2024cdf3d3a05010f (refs/remotes/origin/20080918_DBDEPLOY)
        A       src/database/sds.dbd
[...]

根据其他人的建议,我打开了配置文件(C:\code\Git_myproject.git\config),第一个版本(损坏)如下。与 v2 相比,fetch 可能是错误的(分支和标签也重复,有人说它也可能导致问题)。

[svn-remote "svn"]
noMetadata = 1
url = https://mycompany.svn.beanstalkapp.com/myproject
fetch = :refs/remotes/origin/trunk
branches = branches/*:refs/remotes/origin/*
tags = tags/*:refs/remotes/origin/tags/*
branches = branches/*:refs/remotes/origin/*
tags = tags/*:refs/remotes/origin/tags/*

第二个版本(工作)是:

[svn-remote "svn"]
noMetadata = 1
url = https://mycompany.svn.beanstalkapp.com/myproject
fetch = trunk:refs/remotes/origin/trunk
branches = branches/*:refs/remotes/origin/*
tags = tags/*:refs/remotes/origin/tags/*

查看 svn.pm,我可以看到我们在find_parent_branch()其中输出消息"Found possible branch point"。然后它调用 other_gs($new_url, $url, $branch_from, $r, $self->{ref_id}); which 本身调用: Git::SVN->find_by_url($new_url, $url, $branch_from); which 调用: resolve_local_globs($u, $fetch, $globspec); 并且resolve_local_globs是在第 100/101 行引发错误的地方:

my $u = (::cmt_metadata("$refname"))[0];
$u =~ s!^\Q$url\E(/|$)!! or die

我肯定在命令行中犯了一个错误,修复我的主干路径消除了错误。我从未删除配置文件中的重复行,它们在重新运行命令时自动调整。

于 2016-05-05T10:28:52.887 回答