Reputation: 1864
There are many posts here on Stackoverflow about how to fix your repository when you come across an error like this after doing a git pull
:
error: object file .git/objects/48/088f00d90b0d27de65336bb9ed9a75b0cfed33 is empty fatal: loose object 48088f00d90b0d27de65336bb9ed9a75b0cfed33 (stored in .git/objects/48/088f00d90b0d27de65336bb9ed9a75b0cfed33) is corrupt
What I'm curious to know is: what are examples of things that would cause this error to begin with?
Some questions report things like their system rebooting or their battery dying in the middle of a git pull. This interruption causing the issue makes sense.
Then there are other questions who report that the issue repeatedly happening, such as in this post, with no clear indicator as to why.
Upvotes: 2
Views: 3610
Reputation: 7358
These errors should not happen when changes to the Git repository are carried out using the Git client. From the documentation, see Object Storage to learn how Git stores its objects:
A corrupt loose object is any object whose state deviates from this design (See also What are the “loose objects” that the Git GUI refers to?).
Besides a system reboot or a dying battery, other reasons include
If you're curious, try this contrived example:
$ git init bad-apple
Initialized empty Git repository in /tmp/bad-apple/.git/
$ cd bad-apple
$ touch README; git add .; git commit -m "Add a transitional fossil"
[master (root-commit) ca3ea96] Add a transitional fossil
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
# Get the commit object id
$ git rev-parse HEAD
ca3ea9630c0f01afc286589c4072db9c43262d63
# Git tries to help you not shoot yourself in the foot
$ chmod +w .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63
# Empty out the commit object file and you broke it
$ truncate .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 --size 0
error: object file .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 is empty
error: object file .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63 is empty
fatal: loose object ca3ea9630c0f01afc286589c4072db9c43262d63 (stored in .git/objects/ca/3ea9630c0f01afc286589c4072db9c43262d63) is corrupt
Upvotes: 1