miriup.de

...because open source matters

  • Increase font size
  • Default font size
  • Decrease font size

Recovering a damaged git repository

E-mail Print

Intro

My machine had disk problems. I lost quite a bit of data and it seems I lost one of my git repositories as well.

git log | head
error: Could not read 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc
fatal: Failed to traverse parents of commit 92a2c1a74048cf8caec7ddd27f943652fab147ac

Analyzing the damage

The ref log apparently is still intact:

$ tail -n 3 .git/logs/refs/heads/master
ba6111ef1ebafac3346f816f36c01bc4af6c2734 03c6b33d82e9e9ec1ecea4985fbe1cca994f44e2 Dirk Tilger  1299783879 +0400 commit: Virgin mono-basic checkin
03c6b33d82e9e9ec1ecea4985fbe1cca994f44e2 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc Dirk Tilger  1300007389 +0400 commit: Missing efreet dependency
2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc 92a2c1a74048cf8caec7ddd27f943652fab147ac Dirk Tilger  1300007427 +0400 commit: Missing edje dependency

In the list above the first ID is the commit ID, the second ID is the tree ID. The most recent commit is the last one. The commit object 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc seems damaged:

git log 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc
fatal: bad object 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc

The tree object 92a2c1a74048cf8caec7ddd27f943652fab147ac seems intact:

git ls-tree 92a2c1a74048cf8caec7ddd27f943652fab147ac
040000 tree a82504d023fe31e3ed093e58fc4872e5ccd7a4d9    app-portage
040000 tree 0a52ed4638173345b769ec17091db2285849c789    app-text
040000 tree febb17823eb11421f76188d9900c94d6528a6401    app-vim
040000 tree 466e19ae9676334eba999f20e51e6bbea5570933    dev-lang
040000 tree 78dd40b37ebc0cb9ccd59877b08658024416feab    dev-libs
040000 tree 1d60e8774bd1ba9a2170c5507d5357bcfe7bd11d    media-libs
040000 tree 29b1bb0b660a7a7006d2482a9c5703237e2c273f    media-video
040000 tree 5da17094d77e36eb216074117b1fc869aa80b0ce    www-plugins

The commit object 03c6b33d82e9e9ec1ecea4985fbe1cca994f44e2 seems not damaged:

git log --oneline 03c6b33d82e9e9ec1ecea4985fbe1cca994f44e2 | head
03c6b33 Virgin mono-basic checkin
ba6111e Renamed mono ebuild to 9999 version
1fe38af Mono ebuild from the main tree
4835a15 Rename to git ebuild
7ca911f Moonlight ebuild from the main tree
ef843f2 Added odf-converter ebuild from https://bugs.gentoo.org/show_bug.cgi?id=171182
3dce387 g-pypi from my modified pythonhead
1c0ffb8 Compiler plugin for PyLint ( http://www.logilab.org/projects/pylint/ ), a style checking tool for Python.
283897d Awesome. Completion with manual. :
fa38747 vim tasklist greps out TODO and FIXME

The tree object 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc is damaged:

git ls-tree 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc
fatal: not a tree object

So to repair this repository all we have to do is to recreate commit 2e3f651d6fdd1ca7604df1f3b1424a4c67095ccc by using the working tree object 92a2c1a74048cf8caec7ddd27f943652fab147ac.

Repairing

What has been lost is one commit object. In theory we might be able to look for a tree object that is not referenced either by another tree object or a commit object. However, as in my case the last two commits actually had been accepted upstream, all I really need to do is to change the tip of my branch to before the damaged commit.

git branch -l before-efreet 03c6b33d82e9e9ec1ecea4985fbe1cca994f44e2

When I now checkout, I still get an error, because it tries to see what needs merging and so on:

git checkout before-efreet
fatal: unable to read tree 78dd40b37ebc0cb9ccd59877b08658024416feab

This can be fixed by forcing the checkout and with having made a backup of everything just before, nothing will get lost.

git checkout -f before-efreet
Last Updated on Tuesday, 05 July 2011 08:02  

Comments   

 
0 #56 Guest 2015-05-24 16:46
Hello there! This post could not be written any better! Reading this post reminds me of my good old room mate! He always kept talking about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing! egkeebdeecadkbed
Quote
 
 
0 #55 Guest 2015-05-20 11:42
Article Source a viral game app is not bkddkdfkgbfegdfa
Quote
 
 
0 #54 Guest 2015-05-16 03:26
Write more, thats all I have to say. Literally, it seems as
though you relied on the video to make your point. You clearly know
what youre talking about, why waste your intelligence on just posting videos to your weblog when you
could be giving us something informative to read?

My web page Cialis from canada online
Quote
 
 
0 #53 Guest 2015-05-15 21:47
I believe everything posted made a great deal of sense. However, what about this?
what if you typed a catchier title? I am not suggesting your content is not solid., but what
if you added a title that makes people desire more? I mean Recovering a damaged git repository is
a little boring. You could peek at Yahoo's home page and see how
they write news titles to grab viewers to open the links.
You might add a video or a related picture or two to grab
people excited about everything've written. In my opinion, it might bring your posts a little livelier.


my homepage; followers.guru
Quote
 
 
0 #52 Guest 2015-05-15 02:57
You are my inspiration, I possess few web logs and rarely run out from to brand. adcgefekdadaaffe
Quote
 
 
0 #51 Guest 2015-05-13 12:20
Spot on with this write-up, I really believe that this website needs far more attention. I'll probably be
back again to read more, thanks for the info!

Feel free to surf to my weblog Canadian Pharmacy
Quote
 
 
0 #50 Guest 2015-05-10 02:00
Hi there, just became alert to your blog
through Google, and found that it is really informative. I am gonna watch out for brussels.
I will appreciate if you continue this in future.

Lots of people will be benefited from your writing. Cheers!



Here is my blog - Cheap cialis online canada pharmacy
Quote
 
 
0 #49 Guest 2015-05-08 15:58
When I initially commented I clicked the "Notify me when new comments are added" checkbox and now
each time a comment is added I get three emails with the same
comment. Is there any way you can remove people from that service?
Many thanks!

Here is my blog post :: Can you buy cialis over the counter in canada
Quote
 
 
0 #48 Guest 2015-05-07 01:43
I was wondering if you ever thought of changing the
structure of your site? Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so people could connect with it
better. Youve got an awful lot of text for only having one or two pictures.
Maybe you could space it out better?

Feel free to visit my web blog Cialis canada pharmacy online
Quote
 
 
0 #47 Guest 2015-05-06 19:32
Amazing blog! Is your theme custom made or did you download it from somewhere?
A theme like yours with a few simple adjustements
would really make my blog jump out. Please let me know where you got your
theme. Many thanks

Also visit my homepage - Cialis through canada
Quote
 
 
0 #46 Guest 2015-05-05 21:45
Hello there! This post could not be written any better!
Reading this post reminds me of my good old room mate!
He always kept talking about this. I will forward this page to him.

Fairly certain he will have a good read. Thanks for sharing!



My blog post - India generic pharmaceutical companies
Quote
 
 
0 #45 Guest 2015-04-25 12:23
That is very attention-grabbing, You are a very skilled blogger.
I've joined your feed and stay up for searching for extra of your
magnificent post. Also, I've shared your website in my social networks

Here is my website: Canadian Pharmacies Shipping To Usa
Quote
 
 
0 #44 Guest 2015-04-21 07:52
It's really a cool and useful piece of info. I am happy that you just shared this helpful information with us.

Please stay us up to date like this. Thanks for sharing.



Check out my website: dyson dc24
Quote
 
 
0 #43 Guest 2015-04-17 21:27
What i do not understood is in fact how you're not
really a lot more smartly-appreciated than you might be now.
You are very intelligent. You already know thus considerably relating to this subject, produced me
individually consider it from so many various angles.
Its like women and men aren't involved except it's something to accomplish with Girl gaga!
Your personal stuffs outstanding. Always take care of it up!


Visit my webpage - cheap flights from las vegas
Quote
 
 
0 #42 Guest 2015-04-09 11:42
Hmm it looks like your website ate my first comment (it was extremely long) so I guess
I'll just sum it up what I submitted and say, I'm
thoroughly enjoying your blog. I as well am an aspiring blog blogger but I'm still new to the whole thing.
Do you have any recommendations for first-time blog writers?
I'd genuinely appreciate it.

Also visit my homepage cheap cialis
Quote
 
 
0 #41 Guest 2015-04-08 14:35
Thank you for some other informative website. The place else may I am getting that type of info written in such an ideal way?
I have a venture that I am simply now running on, and I have been at
the glance out for such info.

Also visit my page :: viagraonline2015shopusa.com/
Quote
 
 
0 #40 Guest 2015-04-05 12:51
Link exchange is nothing else however it is simply placing the other person's
webpage link on your page at proper place and other person will also do same in support of you.


Also visit my page - www.viagrabelgiquefr.com/viagra-levitra-cialis
Quote
 
 
0 #39 Guest 2015-04-02 15:57
Hey There. I discovered your weblog using msn. That is an extremely smartly written article.
I will make sure to bookmark it and return to learn more of your helpful information.
Thank you for the post. I'll certainly comeback.

Stop by my web page :: cialis over counter
Quote
 
 
0 #38 Guest 2015-03-30 12:25
It's difficult to find educated people for this topic,
but you seem like you know what you're talking about!
Thanks

Also visit my webpage; assurance auto
Quote
 
 
0 #37 Guest 2015-02-23 23:20
Have you ever thought about creating an ebook or guest authoring on other blogs?

I have a blog centered on the same topics you discuss and
would really like to have you share some stories/information. I know my viewers would enjoy your work.
If you're even remotely interested, feel free to shoot me an email.


Also visit my web site ... generic viagra canada
Quote
 

Add comment


Security code
Refresh