Git - 无法获取/pull/克隆

标签 git github gitlab

我在获取、 pull 或克隆我的存储库时遇到以下错误:

$ git fetch
remote: error: Could not read 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
remote: fatal: bad tree object 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
remote: aborting due to possible repository corruption on the remote side.
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
fatal: protocol error: bad pack header

当我 git -fsck

$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (148557/148557), done.

当我 git prune 然后 git gc

$ git gc
Counting objects: 148557, done.
Compressing objects: 100% (26144/26144), done.
Writing objects: 100% (148557/148557), done.
Total 148557 (delta 90234), reused 148557 (delta 90234)

我在这里搜索了一些解决方案,有些人建议删除对象树或移动它,但是:

$ git ls-tree 9bc3bd2d69d3eeebdbb916f5b6126b7714f90e75
fatal: not a tree object

我应该在这里做什么? (这个 repo 在 gitlab 上,我尝试在 sourcetree 和 git bash 上获取它)

最佳答案

我确认我也不能克隆那个 repo ;)(我可以访问 Jean Henry 的 repo)

我描述了正确的恢复过程 6 years ago , 再次引用 in 2014 .

目标是获取任何仍在运行的最新克隆并解压缩其包文件,以搜索丢失的对象(这里是一棵树)。
参见“How to recover Git objects damaged by hard disk failure?

mv .git/objects/pack/* <somewhere>
for i in <somewhere>/*.pack; do
  git unpack-objects -r < $i
done
rm <somewhere>/*

解压缩后,您可以查找文件 ./git/objects/9b/c3bd2d69d3eeebdbb916f5b6126b7714f90e75:将其复制到服务器上的裸仓库。
并执行 git fsck 以确认错误已消失。

关于Git - 无法获取/pull/克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33869203/

相关文章:

python - 在计算机之间迁移 virtualenv 和 Github

node.js - 无法建立主机 'github.com (192.30.252.128)'的真实性

github - 带有私有(private) git 存储库的 Cocoapods

git - 如何将所有内容回滚到之前的提交

git - 使用 become/become_user 的 Ansible 2.1.0 无法设置临时文件的权限

go - 如何将 Go dep 与 GitLab 子组一起使用

git - 在 GitLab 的 CI/CD 系统中,如果作业在我的 fork 中,我如何阻止它运行,并且只允许它在 merge 到主仓库时运行?

jenkins - 如何从多个 Gitlab 存储库触发一项 Jenkins 作业?

git - 查找包含多个特定提交的 Git 提交

git - 如何在不推送我的情况下从 GitHub pull 更改?