What can I do with Git corruption due to a missing object?
Asked Answered
C

3

11

I just went to clone a repository on another remote server and ran into an issue trying to do so:

git clone [email protected]:blah/blah/docs.git
Cloning into docs...
remote: Counting objects: 343, done.
remote: error: unable to find 14f87a739828e4d489b0310a51e057b30333926e
remote: Compressing objects: 100% (325/325), done.
error: git upload-pack: git-pack-objects died with error.   
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
remote: fatal: unable to read 14f87a739828e4d489b0310a51e057b30333926e
remote: aborting due to possible repository corruption on the remote side.
fatal: early EOF
fatal: index-pack failed

I did a little research and found out about git fsck, here is the output:

$ git fsck --full
error: sha1 mismatch 14f87a739828e4d489b0310a51e057b30333926e

error: 14f87a739828e4d489b0310a51e057b30333926e: object corrupt or missing
missing blob 14f87a739828e4d489b0310a51e057b30333926e

All other people with similar problems have a broken link issue or something. I'm still fairly new with Git, does anyone know how to fix this?

I can still push to my central remote repository, but I can't clone it.

14f87a739828e4d489b0310a51e057b30333926e is a blob that is a markdown file in the repository root. I tried deleting this file and push those changes to no avail.


Edit: Is it possible to import git history from a another repo? I'm thinking I could just start a new repo and copy my files into it and then import the commit history.

Cesium answered 8/2, 2011 at 4:49 Comment(0)
H
3

Here is almost the same question with a very detailed solution: Github Repo Corruption - Sha1 Collision

Holy answered 8/2, 2011 at 7:44 Comment(2)
I've read that, he has the broken link issue which I don't have.Cesium
@Cesium You can also try B) from git.wiki.kernel.org/index.php/… to locate the corrupted fileHoly
D
3

If it's only one single file and it's not packed yet, you should be able to find it in .git/objects/14/f87a739828e4d489b0310a51e057b30333926e in your local repository. You can copy this files to the corresponding directory in the repository on your server.

If it is packed, you should be able to unpack it using git unpack-objects on one of the pack files in .git/objects/pack/. After that, copying to the server works as described above.

Diehl answered 8/2, 2011 at 8:33 Comment(2)
I don't have /14/f887a7.. There is a pack, but when I unpack it, no new object folders are created... and there is only two (01 and c7). It says it's working though Unpacking objects: 100% (346/346), done.Cesium
@Cobby: Better option, independently from whether the object is packed or not, is detailed here: https://mcmap.net/q/375804/-git-corrupted-repo-how-to-pick-a-git-object-from-a-clean-repositoryHippie
A
1

Simple push will not fix this problem, because git sees it has the commit that refers to the corrupt file and will assume it has all the objects it needs.

Do you have another repository with the project that does not report any problems with fsck (and has the file in question)? E.g. on your local machine? Than you should try:

  1. Put the corrupt repository aside.
  2. Clone the good repository in it's place.
  3. Push any branches the old repository had from other repositories or the old repository.

Since this kind of error means the file on disk was corrupt, I suggest you do a thorough check of the filesystem, the disk and also memory (the data could get corrupted in memory when git was saving them).

Note: While all disks have at least some checksums, most memory chips have none at all, so a memory fault is more likely to go undetected than a disk fault. memtest86+ is a good way to check memory.

Andrien answered 8/2, 2011 at 7:9 Comment(6)
Just a side note on memory "checksums" not related to the question / answer: Servers usually use RAM chips with ECC.Diehl
Not only servers support ECC. For instance, workstation mainboards with XEON processors support ECC RAM as well. While it is a little less performant than non-ECC, I still prefer the safety in regards of data integtrity and correction it has. In my case, I use an ASUS P6B WS with a XEON and 6*2GB ECC RAM in a triple channel config, and the performance is perfect.Killoran
@Diehl Well, yes and no. They are not related to recovery from the error, but it is relevant that this kind of error usually indicates a hardware problem and where that problem can be.Andrien
I don't have any other copies of the repository. There is my local version, and the Codebase one. I have an idea, updating my question.Cesium
Oh, my local version of the repository is actually stored on NAS.Cesium
I'm already buying new HDD's for my server. I saw all kind of I/O errors in my /var/log/kern.log. OEI!Langham

© 2022 - 2024 — McMap. All rights reserved.