Git-svn failed with update-ref HEAD refs/remotes/origin/trunk: command returned error: 128

Git-svn failed with update-ref HEAD refs/remotes/origin/trunk: command returned error: 128

我正在尝试将 14.4k 提交和 12 年前的项目从 SVN 迁移到 git。

因为这是进行基本浏览器研究时首先使用的工具,所以我尝试使用 git-svn。 因为它真的很大,所以我尝试从最近的历史中进行迁移,如下所示:

 git svn clone -r 13800 --username=myUsername http://<URL>/collectionOfRepositories/repository1/ProjectA/ --authors-file "authors-transform.txt" --trunk trunk --tags tags --branches branches projectA-git

svn 存储库如下所示:

ProjectA/
    branches/
    shelving/
    tags/
    trunk/
ProjectB/
    branches/
    shelving/
    tags/
    trunk/

我知道它很标准,也是SVN推荐的架构之一。

当运行这个命令我得到结果:

App_Data
Checking svn:mergeinfo changes since r13800: 30 sources, 0 changed
r13800 = 9ca186bbeee33b2e3f6a5adc9d13288042afddd9 (refs/remotes/origin/aBranch                                                                                                                                                                                               )
fatal: refs/remotes/origin/trunk: not a valid SHA1
update-ref HEAD refs/remotes/origin/trunk: command returned error: 128

请注意,这发生在第一次提交时。

我发现 this 这似乎正是我的问题。 This answer 有 3 个建议,第一个已在我当前的命令中使用,第三个将我引向 subgit 工具的其他问题,这将让我专门问另一个问题。 第二个建议建议使用此命令修复 repo :

$ git update-ref refs/heads/master refs/remotes/git-svn
fatal: refs/remotes/git-svn: not a valid SHA1

我不知道“git-svn”是从哪里来的,所以我试着让它适应 mu 这样的情况:

$ git branch --all
  remotes/origin/myBranch #written in red
$ git update-ref refs/heads/master refs/remotes/origin/myBranch

$ git branch --all
* master #written in green
  remotes/origin/myBranch #written in red

除了文件夹中的 .git 存储库,我没有其他文件,当我执行 git log 时,只有一个提交。此外,ProjectA 应该有大约 20 个 b运行ches。 我是否应该以某种方式恢复失败的命令?

Another answer求婚:

Reasons:

    You didn't specify Subversion layout when it was not standard (trunk-tags-branches). Specifically for the error - you have no /trunk.
    You didn't fetch from revision old enough to span at least one commit into trunk (for example, using -r option).
    Combination of the above

我认为我的架构是正确的,600 次修订就足够了,所以...

另外: 我在 windows 环境中,我 运行 在 gitbash and/or 中执行所有这些命令电源外壳。因此我不能使用 svn-all-fast-export/svn2git @Vampire.

我做错了什么?

Was I suppose to somehow resume the command that failed ?

是的,试试git svn fetch。这将完全恢复它。

基本上,git svn clone = git svn init followed by git svn fetch。 (非常类似于 git clone 本身是一个 git init,然后添加一个默认命名为 origin 的远程,然后是 git fetch。)

根据我使用 git-svn 的经验,经常需要对 .git/config 进行一定程度的摆弄,并理解 refs 和 remotes 之间的差异,才能使其按预期工作。

通常,git-svnremote,代表您通过 git-svn“适配器”访问的远程 SVN 服务器。假设地,由于 DVCS 的性质,您可以有一个带有 3 个遥控器的 Git 回购:

  • lab-server
  • cloud-archive
  • git-svn(或者,重命名为 svn-legacy
  • 可能更好

在您的错误消息中看到 origin 遥控器告诉我您可能在某些时候感到困惑,并说 git clone 而不是 git svn clone。我的建议是弄清楚基础知识并获得您正在做的事情的清晰心理模型。文档和 .git/config 可能对此有所帮助。

我没有直接解决我的问题,但我想我明白为什么会这样。 我相信 this answer(我在最初的问题中提到过)关于不使用足够旧的修订版实际上是正确的。

当我尝试从某个修订版克隆时,该修订版对于主干来说可能已经足够旧了,但对于所有分支和标签来说还不够旧

我想所有的分支和标签的修订号必须足够旧,否则,当 git svn 尝试克隆它们时,它找不到任何修订并因此崩溃。

我能够通过省略 --revision 选项并进行完整迁移来解决我的问题。