Git svn失败,更新ref HEAD refs/remotes/origin/trunk:命令返回错误: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

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

我发现这似乎正是我的问题。这个答案有3个建议,第一个建议已经在我当前的命令中使用,第三个建议将我引向子it工具的其他问题,这将使我专门问另一个问题。第二个建议是使用这个命令来修复回购:

$ 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个分支机构。我是不是应该以某种方式恢复失败的命令?

另一个答案是:

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和/或powershell中运行了所有这些命令。因此,我无法使用svn所有快速导出/svn2git@Vampire。

我做错了什么?

我是否应该以某种方式恢复失败的命令?

是,请尝试git svn fetch。这将恢复它,确切地说。

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

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

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

  • lab-server
  • cloud-archive
  • git-svn(或者,也许更好地重命名为例如svn-legacy(

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

我没有直接解决我的问题,但我想我理解为什么会发生这种情况。我相信这个答案(我在最初的问题中提到的(实际上是正确的,没有使用足够旧的修订。

当我试图从某个修订版进行克隆时,修订版可能已经足够旧,可以用于主干,但不能用于所有分支和标签

我想,修订号必须足够旧,才能用于所有分支和标记,否则,当git-svn尝试克隆它们时,它找不到任何修订,从而崩溃。

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

最新更新