Re: rebuild repo from data, packfiles?

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: rebuild repo from data, packfiles?

From: tom fogal <hidden>
Date: 2016-06-15 22:50:04

Hi John, thanks for the help.

Jonathan Nieder [off-list ref] writes:
tom fogal wrote:
quoted
Long story short, I lost some metadata in a repo I've got.
However, my entire .git/objects/ && subdirs is intact, so I'm
hopeful my data's still accessible in some form.
Turns out I'm dumber than I thought =(. I had a lot of trouble with
trees seemingly becoming invalid after a bit... my shell history's got
an rm -r and deleted a lone packfile before I thought "what the hell am
I doing?!" and stopped, so that must be it.
Here's what I'd suggest.
[snip]

The repository-layout info and the lost-found option to fsck were both
new to me, and quite useful.  Thanks!

Where I'm at now: through lost-found, mucking with metadata enough
that git-log and format-patch work, and re-creating a repo to apply
patches onto, I've got a lot of my work back.  There's a 3 or 4 week
gap though, and of course git has trouble dealing with that; some of my
"patches" actually add entire files and the like.

If I git cat-file -p all of the `commit' and `blob' sha1's in
.git/objects, it looks to me like all my code is there, I just need to
get it out somehow.

My thought is to cat-file all my commits, filter out the ones which are
upstream, order them by date, and git-am them back into a repo.

Some of my data only exist in blobs, though... maybe git-diff-tree
can get me the patch I need?  Not quite sure what to diff it with,
though... maybe the most-recent sha1 I have, based on date?

Other ideas would certainly be welcome!

-tom

Re: rebuild repo from data, packfiles?

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:50:04

tom fogal wrote:
My thought is to cat-file all my commits, filter out the ones which are
upstream, order them by date, and git-am them back into a repo.

Some of my data only exist in blobs, though... maybe git-diff-tree
can get me the patch I need?  Not quite sure what to diff it with,
though... maybe the most-recent sha1 I have, based on date?

Other ideas would certainly be welcome!
What did "git fsck" say?

If it is possible to unambiguously recover your data without using any
external knowledge, then that would imply a bug imho --- why doesn't
git do it automatically?  Chances are some objects are missing ---
blobs, trees, commits, or tags --- and you will have to fill in some
information for a full recovery.

Perhaps you have another copy of those objects somewhere.  Have you
ever cloned this repo or pushed to another machine?

Sometimes it is possible to recover some specific object with
detective work; see howto/recover-corrupted-blob-object.txt in the
Documentation directory for an example of that.

git does not use text diffs for its object storage.  The information
the repository can give you directly consists of binary deltas and
full objects.

Are the old refs (branches and tags) intact?  More generally, what
files does

 ls -lR .git

list in the old repository?

Regards,
Jonathan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help