I have met an error before(GIT error: object file is empty)
Then I used the method mentioned in how to fix GIT error: object file is empty?
After I updated the HEAD pointer to a good object, it does work .but when I restart the machine ,the same error(object file is empty) occured.
I tried find . -type f -empty -delete
to delete all the empty files and type git fsck --full
then the new error occured.(GIT error: HEAD: invalid reflog entry xxxxxxxxxxxxxxxx)
Is there anything wrong with my GIT? or just because of my bad operations? And how to fix this problem?
The command to use is git reflog expire --stale-fix --all
The magic here is in the --stale-fix
option which will prune any reflog entries that point to an unreachable commit and that refers to a missing object.
The command to use is
git reflog expire --stale-fix --all
But make sure to use Git 2.31 (Q1 2021)
"git reflog expire --stale-fix
"(man) can be used to repair the reflog by removing entries that refer to objects that have been pruned away, but was not careful to tolerate missing objects.
See commit c809798 (10 Feb 2021) by Johannes Schindelin (dscho
).
(Merged by Junio C Hamano -- gitster
-- in commit e68f62b, 17 Feb 2021)
reflog expire --stale-fix
: be generous about missing objectsSigned-off-by: Johannes Schindelin
Whenever a user runs
git reflog
(man) expire--stale-fix
, the most likely reason is that their repository is at least somewhat corrupt.
Which means that it is more than just possible that some objects are missing.If that is the case, that can currently let the command abort through the phase where it tries to mark all reachable objects.
Instead of adding insult to injury, let's be gentle and continue as best as we can in such a scenario, simply by ignoring the missing objects and moving on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With