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 #298 Guest 2016-05-26 00:28
For hottest information you have to pay a quick visit the
web and on the web I found this web site as a finest
web site for latest updates.

my site: youtu.be
Quote
 
 
0 #297 Guest 2016-05-25 07:00
Hey there, You've done a great job. I will crtainly digg it annd
personally recommend to my friends. I'm sure they'll be
benefited from this weeb site.

Jangan lypa unuk Kunjuni situs Anee demi dapatkan Info lebih
lengkap lagi mengenai tim-ramerth.de. Terima Kasih
Quote
 
 
0 #296 Guest 2016-05-25 00:55
John Wild is vice president of Absolute Access & Security.
1940 Tigertail Blvd, Unit 2 Fort Lauderdale, FL 33004. This
is one of the miracles an auto locksmith can perform.


Here is my blog post :: לחפור זה
Quote
 
 
0 #295 Guest 2016-05-24 16:45
There's definately a great deal to learn about this issue.
I love all the points you have made.

Feel free to surf to my weblog :: מנעולן בירושלים פמסון בועז
Quote
 
 
0 #294 Guest 2016-05-24 00:00
Hi there to every single one, it's in fact a fastidious
for me to go to see this website, it consists
of helpful Information.

Look into my website ... dyson vacuum
Quote
 
 
0 #293 Guest 2016-05-23 19:13
all the time i used to read smaller content that also clear their motive, and that is
also happening with this paragraph which I am reading at this time.



Also visit my web blog: dyson vacuum
Quote
 
 
0 #292 Guest 2016-05-23 18:20
If you want to get a great deal from this article then you have
to apply these techniques to your won website.

Feel free to visit my web site: דרושים
מנעולנים באזור מעלה אדומים
Quote
 
 
0 #291 Guest 2016-05-23 16:27
I have read so many posts regarding the blogger lovers but this post is genuinely a pleasant paragraph,
keep it up.

Have a look at my web blog: dyson vacuum
Quote
 
 
0 #290 Guest 2016-05-23 14:24
Hmm is anyone else encountering problems with the pictures on this blog loading?
I'm trying to find out if its a problem on my end or if it's the blog.

Any responses would be greatly appreciated.

Also visit my website dyson vacuum
Quote
 
 
0 #289 Guest 2016-05-23 04:40
Wе stumbled oᴠer һere coming from a ⅾifferent web pаge and thⲟught I mіght ɑѕ
weⅼl check tɦings out. I like աhat I ѕee so now i am follօwing
you. Look forward to ooking at our web paǥe for a secߋnd time.


Looҝ into mү site :: duffel bag leather (モンスト攻略.gamerch.сom)
Quote
 
 
0 #288 Guest 2016-05-23 01:15
Hey there! I know this is somewhat off topic but I was wondering
if you knew where I could find a captcha plugin for
my comment form? I'm using the same blog platform as yours and I'm having difficulty finding one?

Thanks a lot!

My blog post ... ניהול מוניטין
Quote
 
 
0 #287 Guest 2016-05-22 05:58
In other words, you lost a net 25 calories while breaking down spinach.
Over the coming weeks gradually reduce the time you spend online and eventually you'll have a healthier lifestyle.

If you want to make any of these exercises more
challenging, simply raise the reps or sets.

Also visit my website: Zayıflama
Yöntemleri
Quote
 
 
0 #286 Guest 2016-05-22 01:44
Howdy are using Wordpress for your blog platform?
I'm new to the blog world but I'm trying to get started
and set up my own. Do you need any coding knowledge to make your own blog?
Any help would be greatly appreciated!

Here is my blog post; מנעולן בירושלים דפי זהב
Quote
 
 
0 #285 Guest 2016-05-21 18:55
I read this paragraph completely about the difference of newest and preceding technologies, it's awesome article.


Also visit my blog; פורץ מנעולים בקרית ביאליק
Quote
 
 
0 #284 Guest 2016-05-20 18:47
Have yoս evᥱr consideгeԁ ɑbout adding a little
bit more than just your articles? I mean, what yߋu say is fundamenntal аnd аll.
But tɦink of if you addeⅾ somе great pictures or video
clips tⲟ ɡive your posts morе, "pop"! Your content іs excellent but wіth pics and clips, thіѕ
website ϲould definotely be one of thᥱ best in іtѕ field.

Vеry ցood blog!

Feel free tο surf to mү webpage: golf сlubs hybrid
Quote
 
 
0 #283 Guest 2016-05-20 05:04
Hello! Great stuff here, please keep us posted.


my homepage ... male enhancement exercise
Quote
 
 
0 #282 Guest 2016-05-20 01:55
I got what you imply, thanks for posting. I'm blissful to
find this website via search engines.

my webpage: male enhancement lotion, blog.bizeso.com,
Quote
 
 
0 #281 Guest 2016-05-18 19:11
We want to remove your unwanted The Laserless Tattoo Removal Guide Review as quickly and
as cost effectively as possible.
Quote
 
 
0 #280 Guest 2016-05-17 11:08
However, if you're planning on shooting new footage for the trailer, you need to ensure you can afford to it.

Since its production it's been doing quite nicely as the casting
is cool enough that one can easily derive the theme and specification of the movie.
Watching free movie trailers is definitely a simple activity, with regards with
all the internet and every film worth seeing this Year
too if you like watching the movie trailers before watching your entire movie.
Quote
 
 
0 #279 Guest 2016-05-17 00:15
Hi, I check your blog regularly. Your humoristic style is awesome, keep up the good work!


Feel free to visit my blog post ... youtube.com
Quote
 

Add comment


Security code
Refresh