Corrupt

Having a corrupt git repo is scary.

For the last few weeks I’ve had this blog’s git repo getting randomly corrupted.

Summary: There is a fix on the Windows Dev Insider Build - 21292. I’m currently on stable build of 19042.804

Error: object file is empty

I’ve had this blog’s git repo getting corrupted with errors like:

error: object file .git/objects/79/cbddeb3c2e2e6cb41f301bdf1e10c0508066e3 is empty
error: object file .git/objects/79/cbddeb3c2e2e6cb41f301bdf1e10c0508066e3 is empty
fatal: loose object 79cbddeb3c2e2e6cb41f301bdf1e10c0508066e3 (stored in .git/objects/79/cbddeb3c2e2e6cb41f301bdf1e10c0508066e3) is corrupt

These are sitting on a fully patched Win10 machine (29th Jan 2021) runing WSL2 fully patched. The files are sitting WSL side ie in /home/dave/djhmateer.github.io

Git Version

I had version 2.17.1

Lokking at git-scm I can see the latest is 2.30.0 so lets see if this helps

sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

okay now I’m at 2.30.0

This didn’t work

Fix broken Git repo

Stackoverflow answer

# backup the repo first!
find .git/objects/ -type f -empty | xargs rm
git fetch -p
git fsck --full

Resources and a Fix!

Reddit discussion

Hacker news discussion with a broken link which should be: WSL issue on GH

Updated HN link just in case there is any interesting future discussion.

Fix on dev insider build of insiders preview build 21292 in Mid Jan 2021 21292 announcement

I can’t confirm that it is fixed yet as don’t want to run Dev insider build on my main machine yet.