git error: github.com:abc/xyz.git did not send all necessary objects

I was getting following error when running git pull

git pull
fatal: bad object refs/heads/master 2
error: github.com:abc/xyz.git did not send all necessary objects

I tried running git gc

git gc
error: bad ref for .git/logs/HEAD 2
fatal: bad object refs/heads/master 2
fatal: failed to run repack

The fix was to remove above to files under .git

rm .git/logs/HEAD\ 2
rm .git/refs/heads/master\ 2

After that I was able to run gc and do git pull

git gc
Enumerating objects: 257, done.
Counting objects: 100% (257/257), done.
Delta compression using up to 4 threads
Compressing objects: 100% (224/224), done.
Writing objects: 100% (257/257), done.
Total 257 (delta 85), reused 0 (delta 0), pack-reused 0

One thought on “git error: github.com:abc/xyz.git did not send all necessary objects

  1. Erik

    Thanks! This fixed my issue. Another helpful command is “git fsck” which will show any inconsistencies in the repo’s data.

    Reply

Leave a Reply