DEV Community

loading...

How to fix Git error: object file is empty?

dieunelson profile image Dieunelson Dorcelus Updated on ・1 min read

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

Discussion (0)

pic
Editor guide