GIT: `error: unable to find <commit>` and `fatal: object <commit> not found` on pull

GIT: `error: unable to find <commit>` and `fatal: object <commit> not found` on pull

我们在 Bitbucket 中有一个存储库,我们将其用作中央存储库:

  1. 我们通过拉取请求或直接通过推送更改来更新它,并且
  2. 我们通过拉取来同步远程服务器中的最后更改。

这已经运行了大约一年,但现在我们无法从这个 repo 中提取更改来更新远程服务器:

$ git pull origin
remote: Total 0 (delta 0), reused 0 (delta 0)
error: unable to find a1354e341c6773997c31a109e615d1bf9acb0119
fatal: object a1354e341c6773997c31a109e615d1bf9acb0119 not found

尽管如此,这个 object/commit 可以从 Bitbucket 获得,也可以在我的本地机器上获得(我在这里生成它,然后推送到中央仓库)。

我已经处理这个问题8个多小时了。我对 Git 的了解几乎不足以做一些基本的事情,所以我盲目地尝试了很多可能的解决方案,这些解决方案适用于与我在网上找到的相同情况的其他人,但其中 none 产生了结果。我试过类似的东西:

$ git gc
$ git fsck --full
$ git reflog expire --expire=0 --all

我还重置了 repo 的先前状态并再次重新应用更改,但它也没有用。

关于这个主题的任何线索?

编辑:

Jonathan Swinney 问我尝试克隆存储库时会发生什么。好吧,这有点奇怪。如果我在我的本地机器上克隆它,它工作正常,但它不会通过 SSH 在远程服务器上工作:

$ git clone https://******@bitbucket.org/******/******.git
Initialized empty Git repository in /root/a/idpro/.git/
Password: 
remote: Counting objects: 19853, done.
remote: Compressing objects: 100% (7525/7525), done.
remote: Total 19853 (delta 12910), reused 15843 (delta 10336)
Receiving objects: 100% (19853/19853), 21.12 MiB | 6.00 MiB/s, done.
Resolving deltas: 100% (12910/12910), done.
error: refs/remotes/origin/master does not point to a valid object!
error: Trying to write ref refs/heads/master with nonexistant object c16203dc93b1557fc1d01102ea460663a8112e50
fatal: Cannot update the ref 'HEAD'.

您会注意到 c16203dc93b1557fc1d01102ea460663a8112e50 与上面的 (a1354e341c6773997c31a109e615d1bf9acb0119) 不同,因为我从另一个本地存储库中提取并将更改推送到中央存储库,作为我尝试解决问题的一部分问题。

原来是版本问题。一旦我们更新了我们的 GIT 版本,它就可以正常工作。

sudo yum upgrade –skip-broken –y git

然后再次执行 git –version 它应该告诉你一些 > 1.8

然后尝试 git pull origin 。