git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: Kasra Khosoussi <kasra.mail@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: corrupted Git repository
Date: Tue, 21 Jun 2011 10:19:16 +0200	[thread overview]
Message-ID: <4E005404.5010901@drmicha.warpmail.net> (raw)
In-Reply-To: <BANLkTi=A=DpyfNwEeSd6N6ibCsA5qh_NPQ@mail.gmail.com>

Kasra Khosoussi venit, vidit, dixit 21.06.2011 08:58:
> Hi all,
> 
> My thesis repository is corrupted and I don't have any recent backup
> (my files are OK, but the history is lost). I've seen the recovery

Backup now!
I guess you've done that meanwhile anyways, but it's important before
any recovery attempts.

Is your reflog OK, i.e. do you get proper output from "git reflog" or
"git log -g"?

> examples in the manual, but I believe my case is somehow different.
> The repository is linear.
> 
> 1- At the beginning, git status/log/fsck -full said:
> 
>> fatal: object 0a83757505387aacc2fd36b3c996729e6bf9d6e5 is corrupted

Hopefully and probably only the most recent commit (the one above) is
lost, not all of our history.

> 
> and there was an empty file in .git/objects/01/8375... .

.git/objects/0a83... probably

> 
> 2- If I move the corrupted object, git fsck --ful would return this:
> 
>> error: HEAD: invalid sha1 pointer 0a83757505387aacc2fd36b3c996729e6bf9d6e5
>> error: refs/heads/master does not point to a valid object!
>> dangling tree 06f388dc60cfb014b5e1f70ecdaa568efe6bd0fa
>> dangling tree d86f8c75e836e13b6e0336361641223f48fde722
> 
> 3- I guess I have to edit refs/heads/master and replace the corrupted
> sha1 with another hash, but I'm not sure how I can find the proper
> commit (e.g.,maybe by using find -mtime?).
> 
> Thanks in advance,
> 
> -Kasra

The reflog will give you the previous value of HEAD. You can set
refs/heads/master to that (git update-ref) and then rebuild the lost
commit on top of that (assuming only one commit is lost). The dangling
trees are not necessarily due to the corrupt commit object. Have you
changed any files since the corrupt commit? Do you remember which files
you changed in that commit?

Michael

  reply	other threads:[~2011-06-21  8:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-21  6:58 corrupted Git repository Kasra Khosoussi
2011-06-21  8:19 ` Michael J Gruber [this message]
2011-06-21  9:30   ` Kasra Khosoussi
2011-06-21  9:38     ` Michael J Gruber
2011-06-21 10:10       ` Kasra Khosoussi
2011-06-21 10:39         ` Ilari Liusvaara
2011-06-21 10:40           ` Kasra Khosoussi
2011-06-21 13:47         ` Johannes Sixt
2011-06-21 14:26           ` Kasra Khosoussi
2011-06-21 14:32             ` Carlos Martín Nieto
2011-06-21 14:59               ` Kasra Khosoussi

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=4E005404.5010901@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=kasra.mail@gmail.com \
    /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).