git checkout抛出致命错误引用不是树。

12
我使用Capistrano将代码部署到远程机器上,但是出现了以下错误。我该怎么解决这个问题?
    executing locally: "git ls-remote git@github.com:mycompany/foo.git staging"
    command finished in 468ms
  * getting (via checkout) revision df3d0367fd021d83f881f5d7261dba3f891bca22 to /tmp/20130503165924
    executing locally: git clone -q --depth 1 git@github.com:mycompany/foo.git /tmp/20130503165924 && cd /tmp/20130503165924 && git checkout -q -b deploy df3d0367fd021d83f881f5d7261dba3f891bca22
fatal: reference is not a tree: df3d0367fd021d83f881f5d7261dba3f891bca22

1
你能否添加一些关于你的代码库设置的信息,以及获取此输出所运行的命令? - Matt Kantor
这是一个 GitHub 存储库,git clone 和随后的 checkout 导致了这个问题。 - Rpj
你能否尝试将Capistrano排除在外,自己运行命令(逐个运行)?请编辑您的问题并包括您输入的命令及其输出。 - Matt Kantor
我认为你的答案可能在这里:https://dev59.com/QHI95IYBdhLWcg3wyBGc - sites
看,这里也有一个简短的答案:git submodule sync git submodule update - sites
显示剩余4条评论
2个回答

5

我也曾遇到破损的代码库。在注释掉 Capistrano 的浅克隆选项 (:git_shallow_clone, 1,它生成 --depth 1) 后,部署运行良好。

参见此问题的被接受的答案,详细解释如何可能修复它:Git 子模块 head "reference is not a tree" 错误


1
fatal: reference is not a tree: bf52fb66f4b518bfa579f62db632699ddb127e7b

通常,这个错误是因为您的本地工作区不知道远程存在一个哈希值。您可以运行git fetch命令,然后重新运行checkout命令。
当我尝试将子模块更新到工作区中最新的提交哈希时,我遇到了这个错误。在子模块目录中运行git fetch命令解决了这个问题。

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