DEV Community

Dieunelson Dorcelus
Dieunelson Dorcelus

Posted on • Updated on

How to fix Git error: object file is empty?

Step 1: Make a backup of your .git



# Copy your git folder to git-old
cp -a .git .git-old


Enter fullscreen mode Exit fullscreen mode

Step 2: remove empty files



# Go into the git folder
cd .git/
# Delete all empty files in the curent folder and sub-folders
find . -type f -empty -delete -print


Enter fullscreen mode Exit fullscreen mode

Step 3: check if everything's right



# Verifies the connectivity and validity of the objects in the git folder
git fsck --full
# Show the repos status
git status


Enter fullscreen mode Exit fullscreen mode

If you have more issues, check this topic in stackoverflow it is very helpful

I had a similar problem. My laptop ran out of battery during a Git operation. Boo.

I didn't have any backups. (N.B. Ubuntu One is not a backup solution for Git; it will helpfully overwrite your sane repository with your corrupted one.)

To the Git wizards, if this was a…

When the problem is solved, delete the backup folder :



# Remove the folder git-old
rm -rf .git-old

Enter fullscreen mode Exit fullscreen mode




Sources

Top comments (0)