Git log: fatal object [sha1] is corrupted
Is there any way I can repair my repository with commit history in tact.
# git log
fatal: object 01aeb2bf2e93b238f0e0422816b3e55518321ae7 is corrupted
From reading the link below it looks like I'll have zap it and start over.
开发者_高级运维http://www.miek.nl/s/7e76eadefe/
Do you have clones of this repository elsewhere? You might want to read this post by Linus Torvalds to restore that corrupted object, assuming the corrupted object is a blob (file contents).
I wound up in the same situation, probably due to an improper shutdown of the virtual machine I was working in. There were approximately 10 objects in .git/objects that had zero length. As far as I can tell, the actual source code files were fine, just the repository was hosed.
$ git status
fatal: object fbcf234634ee04f8406cfd250ce5ab8012f92b08 is corrupted
Per some suggestions I saw elsewhere (including Linus's post referenced above), I tried temporarily moving the corrupted objects git was complaining about from .git/objects elsewhere. When had moved all of them, I got:
$ git status
fatal: bad object HEAD
After about an hour of Googling and trying various solutions, I gave up and started a new working copy using 'git clone' to pull from the origin (which was about 2 hours behind my working copy). I then used rsync -rC
(-C excludes SCM files) to copy the changed files from the messed-up working copy to my new working copy.
You could also try to restore these objects by merely copying them from other repositories.
My virtual machine crashed while recording a pushed commit, so the objects were safely stored on a local computer. I scp'ed them to virtual machine and voila — git fsck outputs no errors.
Simply delete the corrupt object that git is complaining about. I was able to resolve the same issue just now this way.
fatal: object 985a4870e7d890b314d2794377045a8b007c7925 is corrupted
For the above error, I was able to find corresponding object at:
project_directory/.git/objects/98/5a4870e7d890b314d2794377045a8b007c7925
Where you can see the file is 0 bytes and deleting it allowed the fetch to start working.
Presumably the previous fetch was interrupted, leaving the corrupt object with size = 0 bytes.
Had the same problem, whichever git command I ran, It ended up with the message:
fatal: object <hash> is corrupted
I didn't have a backup and didn't want to lose my commits, so I decided to try Jase's solution and removed the 0 length file I had : .git/objects/00/<hash>
Then got the same:
$ git status
fatal: bad object HEAD
Then, I tried to know what was wrong and looked into .git/refs/heads/master
where I had the hash.
I looked into .git/logs/refs/head/master
and found lines like this one:
<old commit> <new commit> <author> <timestamp> commit: <commit message>
I removed the last line (which had =) and pasted of this line into .git/refs/heads/master
, erasing its content
I was then able to commit successfully.
I had this same issue. I noticed that I wasn't logged in as root. When I logged in as root, I was able to check the log without the error sign.
To solidify this good status, I did this:
git add .
git commit -a -m "stabilize git"
I exited out of root and tried pulling from a client. It worked out for me afterwards.
When I did the add and commit, I knew that I was fine with what was in the directory. I had no changes visible through "git status".
精彩评论