I have a corrupted loose object.
I tried checkout, revert, rebase and may be few other things to go to an original commit.
In each case I ran git fsck
and still had the same problem:
> git fsck
error: corrupt loose object '25a196217ebb6e341909205575f491022eafc4d9'
fatal: loose object 25a196217ebb6e341909205575f491022eafc4d9 (stored in .git/objects/25/a196217ebb6e341909205575f491022eafc4d9) is corrupt
is there a way to get rid of corrupted objects without simply deleting .git? I don't have another backup so I can't replace the corrupted object.
It's a more narrow question that arose from this git "error: corrupt loose object" after moving a directory
update (1):
> git gc
Counting objects: 747, done.
Delta compression using up to 8 threads.
error: corrupt loose object '25a196217ebb6e341909205575f491022eafc4d9'
fatal: loose object 25a196217ebb6e341909205575f491022eafc4d9 (stored in .git/objects/25/a196217ebb6e341909205575f491022eafc4d9) is corrupt
error: failed to run repack
update (2): this didn't work either Remove file from git repository (history)
update (3): cloning didn't work:
> git clone ../dynamicsCode_good/ .
Cloning into ....
done.
error: corrupt loose object '25a196217ebb6e341909205575f491022eafc4d9'
fatal: loose object 25a196217ebb6e341909205575f491022eafc4d9 (stored in .git/objects/25/a196217ebb6e341909205575f491022eafc4d9) is corrupt
the . directory is empty
update (4): removing a corrupted object.
> git --version
git version 1.7.5.4
> rm -f .git/objects/25/a196217ebb6e341909205575f491022eafc4d9
13:42:57 ~/Dropbox/work/dev/dynamicsCode_torek
> git fsck --full
missing blob 25a196217ebb6e341909205575f491022eafc4d9
dangling tree 64a970c878fef7deeeb4ce2ffc5e6234a72894ad
dangling tree 528e6c121fb8e56097462b2ebb9ec4de66388ce2
first (initial) comment. this comment doesn't even have the corrupted file.
> git log |tail -5
commit 150ceebafb9c20769386cc7ffba07f6e6565fae6
Author: Kirill ...gmail.com>
Date: Tue Sep 27 22:51:15 2011 -0400
state takes input as input
checkout:
> git checkout -b 150ceebafb9c20769386cc7ffba07f6e6565fae6
Switched to a new branch '150ceebafb9c20769386cc7ffba07f6e6565fae6'
> git gc
Counting objects: 783, done.
error: unable to find 25a196217ebb6e341909205575f491022eafc4d9
Compressing objects: 100% (776/776), done.
fatal: unable to read 25a196217ebb6e341909205575f491022eafc4d9
error: failed to run repack
> git fsck --full
broken link from tree 4668817140320ad2e04aa946d95dec2c3885d97b
to blob 25a196217ebb6e341909205575f491022eafc4d9
missing blob 25a196217ebb6e341909205575f491022eafc4d9
dangling tree 64a970c878fef7deeeb4ce2ffc5e6234a72894ad
dangling tree 528e6c121fb8e56097462b2ebb9ec4de66388ce2
I also tried unpacking the only object in the .git/objects/pack/
directory. didn't help.
I also cloned this state into a new directory:
> git gc
Counting objects: 662, done.
error: unable to find 25a196217ebb6e341909205575f491022eafc4d9
Compressing objects: 100% (656/656), done.
fatal: unable to read 25a196217ebb6e341909205575f491022eafc4d9
error: failed to run repack
14:40:34 ~/Dropbox/work/dev/dynamicsCode_torek_commit_clone
> git fsck
broken link from tree b5ab6b287804d5069a3c8648ace38d9d9feac1a5
to blob 25a196217ebb6e341909205575f491022eafc4d9
dangling commit dad8edc620248d3911b7b1c0a99608a64e0288a3
missing blob 25a196217ebb6e341909205575f491022eafc4d9
dangling tree 64a970c878fef7deeeb4ce2ffc5e6234a72894ad
dangling commit ae2b2a9edb744d9e91aa78891c849d5a0040ea94
dangling commit 32ed79bd4ac70b118d046cb6093a4710562e95ba
dangling commit 7e45ef0c6ffc46401b1f82bcbf0f7e843abf9e31
dangling tree 528e6c121fb8e56097462b2ebb9ec4de66388ce2
14:40:40 ~/Dropbox/work/dev/dynamicsCode_torek_commit_clone
> git branch
* 150ceebafb9c20769386cc7ffba07f6e6565fae6
didn't help either.
The corrupted file is tags
from ctags. I don't need it. it's strange that i can't rebuild git without that file. Most importantly, from all my research I don't see neither how it can be done nor why it's not possible.
update (5): checkout without branching
> git checkout 150ceebafb9c20769386cc7ffba07f6e6565fae6
Note: checking out '150ceebafb9c20769386cc7ffba07f6e6565fae6'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at 150ceeb... state takes input as input
16:41:40 ~/Dropbox/work/dev/dynamicsCode_torek_commit
> git fsck --full
broken link from tree 4668817140320ad2e04aa946d95dec2c3885d97b
to blob 25a196217ebb6e341909205575f491022eafc4d9
missing blob 25a196217ebb6e341909205575f491022eafc4d9
dangling tree 64a970c878fef7deeeb4ce2ffc5e6234a72894ad
dangling tree 528e6c121fb8e56097462b2ebb9ec4de66388ce2