From: Junio C Hamano <gitster@pobox.com>
To: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: git@vger.kernel.org
Subject: Re: Recovering from missing objects?
Date: Thu, 19 Feb 2009 16:29:12 -0800 [thread overview]
Message-ID: <7vvdr6j6hz.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LRH.2.00.0902191447040.16988@vixen.sonytel.be> (Geert Uytterhoeven's message of "Thu, 19 Feb 2009 15:08:23 +0100 (CET)")
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com> 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 </var/tmp/$IT.raw
After that you may find objects that $IT needs to reference. You can
obviously repeat the above procedure until you have nothing missing.
I also suspect you could do this instead; I haven't thought things through
and that is why I say "suspect" but this is safe (i.e. not destructive)
and may worth a try.
In the new clone:
$ IT=c406ab0be69c912ea59233595a071478103cdad8
$ H=$(git rev-list --objects $IT | git pack-objects mine)
$ mv mine-$H.pack /var/tmp
Go to the repository that lacks the object and then
$ git unpack-objects </var/tmp/mine-$H.pack
next prev parent reply other threads:[~2009-02-20 0:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-19 14:08 Recovering from missing objects? Geert Uytterhoeven
2009-02-20 0:29 ` Junio C Hamano [this message]
2009-02-20 2:58 ` Jeff King
2009-02-20 6:09 ` Junio C Hamano
2009-02-20 6:10 ` Jeff King
2009-02-20 14:31 ` Geert Uytterhoeven
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7vvdr6j6hz.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).