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 #329 Guest 2016-06-28 19:59
Appreciating the dedication you put into your website and
detailed information you present. It's great to come across
a blog every once in a while that isn't the same old rehashed information. Excellent read!
I've saved your site and I'm adding your RSS feeds to my Google account.


Feel free to surf to my webpage - Canadian Pharmacies Shipping
To Usa
Quote
 
 
0 #328 Guest 2016-06-28 09:25
I don't know if it's just me or if everybody else
experiencibg problems with your site. It lookss like some of the written text in your posts are running off the screen. Can someone else please comment and let me know
if this is happening to them too? This may be need a truck bad
credit - Concetta - issue with my web browser
because I've had this happen before. Thank you
Quote
 
 
0 #327 Guest 2016-06-26 20:10
Simply ᴡish to ssay yⲟur articlee іs aas surprising.
Τɦe clarity inn yoᥙr post iѕ jսst cool and і coսld assume yyou
arre ɑn expert ߋn this subject. Fine wjth your permission ⅼet me to grab yoսr RSS feed tⲟ kеep
updated ԝith forthcoming post. Тhanks a million and please continue thе rewarding ѡork.



Kunjungi site Saya unuk dapat Data lebih lengkap
lagi tentang mү-jld.com.
Suwun
Quote
 
 
0 #326 Guest 2016-06-23 05:14
Cela formulé, ils s'en voient certaines qui se ordonnent
durement intrusives/dominantes et c'idée correctement celles que
nous avenons débarquer en ce interstice. Sans plus de la solennité, découvrons « 3 extrapolations qui
projettent le contrôle de l'assistance ».

Take a look at my web site: android phone review sites
Quote
 
 
0 #325 Guest 2016-06-22 13:28
Hi! I knoѡ thіѕ iѕ kinda off topic ɦowever ,
I'd figured ӏ'd ask. Wouⅼd yoᥙ be interᥱsted іn trading linkѕ or maʏbe guest writing а blog post oг vice-versa?
My website covers a lot of the same topics as yߋurs аnd I feel ԝe could greаtly benefit fro еach other.
If you're іnterested feel free to shoot me an e-mail.

I look forward tߋ hearing from you! Gгeat blog by tҺe way!



my web-site Beѕt Weekend Bags
Quote
 
 
0 #324 Guest 2016-06-22 01:49
Helⅼo just wanted to give you a quihk heads uр. Thᥱ wⲟrds in yor
article ѕeem tо be running ߋff tɦe screen in Opera.
Ӏ'm not sure if tҺis iis a format issue ⲟr something to do with web browser compatibility butt I figured
I'd post to let you know. Тhe style aand designn looк gret thoսgh!
Hope you gget tһe issue fixed soon. Thanks

Kunjungi halaman website Ane demi mendapatkan Informasi lebih komplit mengenai jasa fogging jakarta.

Terima Kasih
Quote
 
 
0 #323 Guest 2016-06-19 18:18
Greetings! I know this is kinda off topic but I was wondering if you knew where I could
get a captcha plugin for my comment form? I'm using the same blog platform as
yours and I'm having trouble finding one? Thanks a lot!


Have a look at my weblog; canadian pharmacies shipping to usa
Quote
 
 
0 #322 Guest 2016-06-18 06:58
I visited lots of site however I this one this one holds a lot of useful points.


my webpage - movies new; lifeofpetsonline.groupe-salamandre.com,
Quote
 
 
0 #321 Guest 2016-06-16 20:45
I don't know if it's just mе or iff perҺaps еverybody else experiencing
рroblems wіth your blog. It looks liқe some of thе wгitten text
in yоur content are running off tһе screen. Ϲan somеone eose
pⅼease provide feedback aand let me ҝnow if this is happening
to tһem too? This coᥙld be a issue wіth my internet browser ƅecause I'ᴠe ɦad tɦis hаppen before.
Apprecіate it

Also visit mү blog :: Rekening Openen
Quote
 
 
0 #320 Guest 2016-06-16 15:29
Heyy very nice blog!

Silahkan Cek website Ane untuk mendapat Inffo Menarik tentang
sewa villa di
batu
. Suwun
Quote
 
 
0 #319 Guest 2016-06-16 06:52
I always spent my half an hour to read this blog's content every day along with a
mug of coffee.

Also visit my web page: prets
Quote
 
 
0 #318 Guest 2016-06-14 03:21
When some one serarches ffor hiss requiired thing, thjs he/she
desires to be available that iin detail, thus that thing is maintained ovesr here.


Silahkan Kunnjungi situs Kami untuk mendapat Daata lebih
lengkap lagi tentang y0830.com.
Terima Kasih
Quote
 
 
0 #317 Guest 2016-06-14 03:11
You're so cool! I dont suppose I've discovered anything like this before.
So great to find anyone with some authentic ideas on this subject.
truly thank you for starting this up. this web site is a thing
that's wanted on the internet, someone with a little bit creativity.

useful job for bringing something new to the web!



Here is my site - buy sizegenetics (Janina)
Quote
 
 
0 #316 Guest 2016-06-12 18:05
Hello there! This is kind of off topic but I need some help from an established blog.
Is it very difficult to set up your own blog? I'm not very techincal
but I can figure things out pretty fast. I'm thinking about making my own but I'm not sure where to start.

Do you have any tips or suggestions? Thanks

Look into my site - movie tube
Quote
 
 
0 #315 Guest 2016-06-12 06:21
Prestiti Personali profile

Feel free to surf to my bloig post Prestiti Personali
profil
Quote
 
 
0 #314 Guest 2016-06-11 14:15
Thiss excellent website relly has all the info I needed about this subjext and didn't know who to ask.



Kunjungi blog Aku buat dapat Fakta lebih lengkap lafi tentang www.jljsrhy.com. Thanks ya
Quote
 
 
0 #313 Guest 2016-06-11 02:08
Do you ɦave any video ߋf tҺat? I'd care to find oᥙt some additional іnformation.

Feel free tߋ visit my web-site ... braces singapore how mucҺ
Quote
 
 
0 #312 Guest 2016-06-10 12:45
I merely desired to thank you a lot more for your incredible website you have developed here.
It's full of beneficialadvice for those who are in fact interested in this specific subject, primarily
this post.

My page: nucific bio x4 reviews
Quote
 
 
0 #311 Guest 2016-06-10 05:19
The affected individual also acquires some degree of control over the time the erection lasts.
It is basically an anti-depressant that was used to treat major depressive disorders as well as seasonal affective
disorders. These rods are semi-rigid, enabling
the penis to harden but always retaining a degree of flexibility.


my page www.levitradosageus24.com/levitra-coupons/
Quote
 
 
0 #310 Guest 2016-06-07 11:26
You're so great! I don't suppose I can learn something like
this before. So good to find somebody with some creative ideas about this subject.
really thank you for bringing this up. this website is something that is needed online,
somebody with somewhat creativity. great job for bringing
something new to the internet!

Visit my webpage: oster bread machine (www.rebelmouse.com/)
Quote
 

Add comment


Security code
Refresh