Git 子模块检出错误:“致命:引用不是树”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30348615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:01:40  来源:igfitidea点击:

Git submodule checkout error: "fatal: reference is not a tree"

gitgit-submodules

提问by Faheem Mitha

For reference, see the issue https://github.com/drmeister/clasp/issues/98

如需参考,请参阅问题https://github.com/drmeister/clasp/issues/98

To reproduce, do the following:

要重现,请执行以下操作:

git clone git://github.com/drmeister/clasp claspcl
cd claspcl
git checkout tags/0.3-test-3
git submodule update --init

The result is:

结果是:

git submodule update --init
Submodule 'updatedAsdf' (https://github.com/drmeister/asdf.git) registered for path 'src/lisp/kernel/asdf'
Submodule 'src/lisp/kernel/contrib/sicl' (https://github.com/drmeister/SICL.git) registered for path 'src/lisp/kernel/contrib/sicl'
Submodule 'src/mps' (https://github.com/Ravenbrook/mps-temporary) registered for path 'src/mps'
Cloning into 'src/lisp/kernel/asdf'...
remote: Counting objects: 13416, done.
remote: Total 13416 (delta 0), reused 0 (delta 0), pack-reused 13416
Receiving objects: 100% (13416/13416), 5.34 MiB | 838.00 KiB/s, done.
Resolving deltas: 100% (9935/9935), done.
Checking connectivity... done.
Submodule path 'src/lisp/kernel/asdf': checked out 'dcd692a8f9f6a5cb86133123e1c433a9afb4e7e9'
Cloning into 'src/lisp/kernel/contrib/sicl'...
remote: Counting objects: 49356, done.
remote: Total 49356 (delta 0), reused 0 (delta 0), pack-reused 49356
Receiving objects: 100% (49356/49356), 8.49 MiB | 298.00 KiB/s, done.
Resolving deltas: 100% (37020/37020), done.
Checking connectivity... done.
fatal: reference is not a tree: 280c12ab49223c64c6f914944287a7d049cf4dd0
Cloning into 'src/mps'...
remote: Counting objects: 25250, done.
remote: Total 25250 (delta 0), reused 0 (delta 0), pack-reused 25250
Receiving objects: 100% (25250/25250), 86.87 MiB | 831.00 KiB/s, done.
Resolving deltas: 100% (15851/15851), done.
Checking connectivity... done.
Submodule path 'src/mps': checked out '3e6640e7eeb5d086adec18e6227a84da59898e1c'
Unable to checkout '280c12ab49223c64c6f914944287a7d049cf4dd0' in submodule path 'src/lisp/kernel/contrib/sicl'

As you can see, the reproduction recipe does not touch the siclsubmodule. So, my best guess is that the claspGit repository has a spurious reference to 280c12ab49223c64c6f914944287a7d049cf4dd0somewhere inside it. The folks on #git also seemed to think this was plausible. As you can see, the reproduction recipe does not touch the siclsubmodule. So, how best to resolve this problem? What kind of surgery is required for the claspGit repository?

如您所见,复制配方不涉及sicl子模块。所以,我最好的猜测是claspGit 存储库对其中的280c12ab49223c64c6f914944287a7d049cf4dd0某个地方有一个虚假的引用。#git 上的人似乎也认为这是合理的。如您所见,复制配方不涉及sicl子模块。那么,如何最好地解决这个问题呢?claspGit存储库需要什么样的手术?

NOTE: the problem does not show up without the git checkout tags/0.3-test-3step. So the problem is presumably in that particular branch, here fixnum.

注意:如果没有git checkout tags/0.3-test-3步骤,问题不会出现。所以问题大概出在那个特定的分支上,这里fixnum.

回答by CodeWizard

I followed your instructions and was able to reproduce the problem.
Its not something you did, the object 280c12ab49223c64c6f914944287a7d049cf4dd0is corrupted and there is nothing you can do in order to fix it.

我按照您的指示操作,并且能够重现该问题。
这不是您所做的,对象280c12ab49223c64c6f914944287a7d049cf4dd0已损坏,您无能为力来修复它。

I manged to do a workaround and to get the content of master:

我设法做一个解决方法并获取 master 的内容:

git show 280c12ab49223c64c6f914944287a7d049cf4dd0
(will display bad object)
cd sicl
git checkout clos
git branch -d master
git fetch --all --prune
git checkout master
git fsck

After the above steps the git show 280c12ab49223c64c6f914944287a7d049cf4dd0still display bad-object (since its a problem in the original repository)

经过上述步骤后,git show 280c12ab49223c64c6f914944287a7d049cf4dd0仍然显示坏对象(因为它在原始存储库中存在问题)

But what that is more strange is the git fsckdoes not find any errors, i will look into it later on today.

但更奇怪的是git fsck没有发现任何错误,我将在今天晚些时候研究它。

As for now the workaround will allow you to continue your work.

至于现在,解决方法将允许您继续您的工作。