无法签出特定分支

Can't check out specific branches

我根据 Vincent Driessen's model 在我的存储库中创建了几个分支。

经过长时间的开发,当我使用 git bash branch 命令时,它告诉我,

$ git branch
  develop
  f7-body-force
  f8-eos
  f9-contact-angle
* f9-junk
  master

分支 f9-junk 来自 f9-contact-angle。现在 f9-junk 已经完成,我想将它合并回 f9-contact-angle,但是当试图检查 f9-contact-angle 时,git 给出了这个错误:

$ git checkout f9-contact-angle
  fatal: reference is not a tree: f9-contact-angle

检查其他一些分支也会产生同样的错误。所以,我尝试了 Visual Studio Git。再次检查 f9-contact-angle:

时出错
An error occurred.
Detailed message: The tip of branch 'develop' is null.
There's nothing to checkout.

问题是什么?

听起来您的存储库已损坏(存储驱动器上的位损坏、意外删除的文件……)

git rev-parse branchname 应该告诉您分支指向哪个提交。从理论上讲,您应该能够直接检查该提交并使用 git cat-file -t commithash 之类的命令来获取对象的类型 ("reference is not a tree")。

运行 git fsck 将对您存储库的数据库文件进行完整性检查。通常它只打印良性消息,例如 "dangling blob/tree/commit",但如果你得到 "invalid sha1 pointer" 或 "missing commit",那么你的 repo 就坏了。您可能需要从备份(或远程存储库)恢复。

远程存储库不应受到本地损坏数据库的影响(您将无法推送)。