If you ever encountered the following issue, keep reading to fix it:
TEXT
1$ git status
2error: object file .git/objects/42/123456789abcde123456789abcde is empty
3error: object file .git/objects/42/123456789abcde123456789abcde is empty
4fatal: loose object 123456789abcde123456789abcde (stored in .git/objects/42/123456789abcde123456789abcde) is corrupt
5$ git pull
6error: object file .git/objects/42/123456789abcde123456789abcde is empty
7fatal: loose object 123456789abcde123456789abcde (stored in .git/objects/42/123456789abcde123456789abcde) is corruptNavigate to the root of your git repo directory (the root should contain a
.gitfolder, checkls -laand look for the.gitfolder at the top):
Run the following command:
BASH1find .git/objects -size 0 -deletefindlooks for all files in the directory.git/objectswith size0and deletes themRun
git pulland check if the output is correct. If it is, you removed all corrupted objects and therefore fixed the issue.
Tip
If this error keeps happening, consider making a backup of the files in your repo without the.git directory and clone a clean repo from the remote.
After that replace the contents with your backup and commit + push the changes to the remote.