Step 1: Make a backup of your .git
# Copy your git folder to git-old
cp -a .git .git-old
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
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
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
Sources
- https://stackoverflow.com/questions/11706215/how-to-fix-git-error-object-file-is-empty/12371337#12371337
- https://man7.org/linux/man-pages/man1/cd.1p.html
- https://man7.org/linux/man-pages/man1/cp.1.html
- https://man7.org/linux/man-pages/man1/find.1.html
- https://man7.org/linux/man-pages/man1/rm.1.html
- https://git-scm.com/docs/git-fsck
- https://git-scm.com/docs/git-status
Top comments (0)