git 'did not receive expected object' error when trying to update GitHub repo

3.8k views Asked by At

I have a personal GitHub Pages set up for a blog, using Pelican. It was working ok, but I decided to start fresh with the content, and instead of cloning from the remote repo, I just started completely from zero on my machine. That is possibly the source of my problems.

When the new local version was working ok, I tried to push the relevant branch. The branch in question is set up automatically by a module gh-export, which puts the directory with the website content at the top-level of that branch so that it will work with GitHub Pages.

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

I got the following error:

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'

I tried pushing all sorts of permutations of branches and directories, so the problem seems to be the pushing or with the local or remote directories rather than the specific thing I'm pushing.

Many thanks in advance!

Tried to push local branch to remote repo on GitHub, expected remote files to be updates to match local version.

2

There are 2 answers

2
randogoth On

I had a very similar problem. GitHub would refuse my push.

It turned out that my branch was a shallow clone of a remote BitBucket repo that I couldn't access anymore, so no chance to do a proper git fetch --unshallow.

This solution worked for me.

1
Muhammad Umar Gulzar On

There is an easier way. All you need to do is to delete the .git from your local repo. Then reinitialize the repo with git init. Then attach your new remote origin with your local repo and push.