From: Junio C Hamano Date: Fri, 20 Feb 2009 00:29:12 GMT Subject: Re: Recovering from missing objects? Message-ID: <7vvdr6j6hz.fsf@gitster.siamese.dyndns.org> In-Reply-To: Geert Uytterhoeven writes: > Hi all, > > I start to see suspicious messages about missing objects in one of my working > repositories: > > | vixen$ git gc > | error: Could not read c406ab0be69c912ea59233595a071478103cdad8 > | fatal: bad tree object c406ab0be69c912ea59233595a071478103cdad8 > | error: failed to run repack > | vixen$ > > My setup: > - I have one reference repository (cloned from Linus' linux-2.6.git) > - I have several working repositories, cloned using --reference to my > reference repository. A working repository has several remotes (cloned from > other Linux kernel repositories). > > I always do a `git pull' in the reference repository, before doing a `git > remote update' in a working repository. When I do `git gc' in a working > repository, it cleans up all objects that are not in the reference repository. > Hence I only need to care about backup of the .git directories in the working > repositories (the stuff I'm working on), and not about the reference > repository (its objects are publicly available and replicated all over the > world). > > I identified the missing object listed above to be part of a remote repository. > Doing a `git remote update' doesn't fetch it again, as git is too smart and > thinks I already have everything. > > If I clone the remote repository, I have the object in the new clone. > However, how do I get the missing object back into the .git directory of my > working repository? In the new clone: $ IT=c406ab0be69c912ea59233595a071478103cdad8 $ TYPE=$(git cat-file -t $IT) $ git cat-file $TYPE $IT >/var/tmp/$IT.raw Go to the repository that lacks the object and then $ git hash-object -t $TYPE -w --stdin