Git SVN:模糊参数“HEAD”

8
   $ git svn clone -s http://a_repo local_dir ( by default this brings me r1 ) to hdd
    Initialized empty Git repository in d:/Temp/local_dir/.git/
    r1 = some_SHA (refs/remotes/trunk)

   $ cd local_dir
   $ git svn rebase
   fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
   Use '--' to separate paths from revisions
   log --no-color --no-decorate --first-parent --pretty=medium HEAD: command returned error: 128

我该如何实际检出仓库?

我也尝试过不使用变基,而是使用fetch,但它每次只能带来一个版本。我们有几千个提交,按照这种速度,复制存储库需要数天时间。


你的意思是 git svn clone 只带来了一个版本?你使用了 -s,你的 SVN 仓库真的是标准布局吗?通常,git svn clone 还应该创建一个工作副本。 - eckes
3个回答

9

如果你从SVN仓库中只获取了一个提交,我会认为SVN仓库不符合标准布局,但你告诉 git svn 它符合标准布局。

git svn clone http://a_repo local_dir

没有-s标志的情况下,应该能够克隆SVN仓库。如果这样可以,请重试克隆并按照git-svn文档中描述的指定您的主干、标签和分支目录。


我的存储库采用标准布局。我还尝试了通过-T指定主干作为参数,但结果相同。我记得在某个地方读到过,如果你通过“fetch”开始svn克隆,那么只能通过“fetch”继续。也许这就是为什么“fetch”“有效”的原因(每次调用只获取一个修订版本)?因为git克隆是init后跟随的fetch? - Senthess
我已经下班了,很遗憾我现在无法测试。我会在明天早上写出结果。我正在克隆到一个新的目录(克隆之前不存在任何文件)。 - Senthess
clone会带来前15个修订版本然后停止。之后我开始了一个fetch操作,但它仍然每次只带来一个修订版本。 - Senthess
@Senthess:那么你应该会收到一个连接已断开的消息。在这种情况下无法帮助你... - eckes
3
你有没有想出解决这个问题的方法?我也遇到了同样的问题。 - mwjackson
显示剩余4条评论

2
当你克隆一个分支而不是整个SVN库时,会出现这个错误。
如果你的仓库URL看起来像https://svnserver/project/repo/trunk或者https://svnserver/project/branches/pre-something,请将克隆命令更改为:
git svn clone https://svnserver/project/repo --stdlayout

2
git svn clone [your-repo-url] -s
# OR 
git svn clone [your-repo-url] -T [your-trunk-dir] -t [your-tags-dir] -b [your-branches-dir]

如果您不指定 -r 标志(如上所示),则需要进行以下操作:
git svn fetch  

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接