尝试更新 GitHub 存储库时出现“git 未收到预期对象”错误

问题描述 投票:0回答:2

我使用 Pelican 为博客设置了个人 GitHub Pages。它工作正常,但我决定从内容开始,而不是从远程存储库克隆,而是在我的机器上完全从零开始。这可能是我问题的根源。

当新的本地版本工作正常后,我尝试推送相关分支。有问题的分支是由 gh-export 模块自动设置的,该模块将包含网站内容的目录放在该分支的顶层,以便它可以与 GitHub Pages 一起使用。

git push [email protected]:JonathanMair/JonathanMair.github.io.git gh-pages:master -f

我收到以下错误:

Enumerating objects: 330, done.
Counting objects: 100% (330/330), done.
Delta compression using up to 10 threads
Compressing objects: 100% (134/134), done.
Writing objects: 100% (330/330), 7.01 MiB | 4.04 MiB/s, done.
Total 330 (delta 112), reused 329 (delta 112), pack-reused 0
remote: Resolving deltas: 100% (112/112), done.
remote: fatal: did not receive expected object 44b304cd6f8a4df85530c3e3bd3f1c6ce800490f
error: remote unpack failed: index-pack failed
To github.com:JonathanMair/JonathanMair.github.io.git
! [remote rejected] gh-pages -> master (failed)
error: failed to push some refs to 'github.com:JonathanMair/JonathanMair.github.io.git'

我尝试推送分支和目录的各种排列,因此问题似乎是推送或本地或远程目录,而不是我推送的具体内容。

提前非常感谢!

尝试将本地分支推送到 GitHub 上的远程仓库,期望远程文件更新以匹配本地版本。

github github-pages pelican
2个回答
8
投票

我有一个非常相似的问题。 GitHub 会拒绝我的推送。

事实证明,我的分支是远程 BitBucket 存储库的浅层克隆,我无法再访问它,因此没有机会进行适当的

git fetch --unshallow

这个解决方案对我有用。


0
投票

有一个更简单的方法。您所需要做的就是从本地存储库中删除 .git。然后使用

git init
重新初始化存储库。然后将新的远程源附加到本地存储库并推送。

© www.soinside.com 2019 - 2024. All rights reserved.