我已经将一个GitHub仓库克隆到了本地机器。 我想要我的本地仓库的状态反映特定提交时的状态,因此我的直觉是使用git checkout <commit>
命令。 然而,这样做会导致错误:
fatal: reference is not a tree: 7aa823a959e1f50c0dab9e01c1940235eccc04cc
在GitHub上查看提交时会出现以下警告:
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
我的选择是什么?如果有帮助的话,GitHub存储库是Linux内核源代码树,相关提交是7aa823a959e1f50c0dab9e01c1940235eccc04cc。
git cat-file -t 7aa823a959e1f50c0dab9e01c1940235eccc04cc
查看存储库中是否存在该对象(它可能不存在)。GitHub在Git的背后使用一些花哨的东西来将分叉的存储组合起来,这意味着有时您可以通过其Web界面“看到”实际上并不存在的提交。这似乎是这样一个情况。如果您能够找出哪个分支实际上持有该提交,那么您可以克隆该分支。 - torek