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 #272 Guest 2016-05-01 16:16
Hi there just wanted to give you a quick heads up.
The text in your post seem to be running off the screen in Opera.
I'm not sure if this is a formatting issue or something to do with internet browser compatibility but I figured I'd post to let you know.
The design look great though! Hope you get the problem resolved soon.
Thanks

my website :: www.dyson.com
Quote
 
 
0 #271 Guest 2016-05-01 05:57
I am really impressed alonjg with your writing skills andd also with
the format to your weblog. Is this a pasid topic or did you customize
it yourself? Anyway say upp the excellent quality writing, it is rare to peer a nice weblog liike this one today..



Feel free to visit my site - dyson dc65 animal
Quote
 
 
0 #270 Guest 2016-04-30 10:07
" "The site is secured as well as Pfizer knows how.
The body has 11 different kinds of PDE enzymes but only PDE 5
is found in the penis. Are you on statins or fibrate
derivatives for your cholesterol.

Here is my page ... www.laviagraes.com/viagra-generico-precio-peru
Quote
 
 
0 #269 Guest 2016-04-27 22:28
I'm curious to find out what blog platform you happen to be utilizing?
I'm experiencing some minor security issues with my latest website and I'd like to find something more risk-free.
Do you have any recommendations?

my site: you could check here
Quote
 
 
0 #268 Guest 2016-04-24 12:45
Heya i'm for the first time here. I found this boaard andd I find It reawlly useful & it helpedd mee out
a lot. I hope to guve something back and aid others ljke
you aided me.

Silahkan Cek halaman website Aku buat dapatkan Informasi lebih komplit tentang
cara cepat alami menurunkan gula darah tinggi.
Suwun
Quote
 
 
0 #267 Guest 2016-04-24 06:01
We have listed some tips that they average renter can use
when their looking for another apartment. It's a wonderful
tool for both owners and those looking to buy or rent.
These will depend on which state you live in so make sure you know what your responsibilities and rights are from the start.


My homepage gables residential cherry
creek
Quote
 
 
0 #266 Guest 2016-04-23 10:30
Thank you for the auspicious writeup. It in reality used to be a entertainment account it.
Glance complex to far added agreeable from you!
However, how could we communicate?

Here is my page ... cialis pharmacy
Quote
 
 
0 #265 Guest 2016-04-22 15:03
Or buy new furniture with the intention of selling it before you leave.
Before signing the lease, read it over, and make sure you understand all the conditions of the lease.
buying a house is out of the question for whatever
reason, apartment rentals might be the next best choice.


Also visit my web blog hartford21 residential (hartford21.jigsy.com)
Quote
 
 
0 #264 Guest 2016-04-22 00:25
You can use any type of projector in an educational way. Read through
the different ingredients, check reviews and be sure to ask a doctor’s
or herbalist’s advise before proceeding. If you intend to make your metal objects last longer, then Permalac is the solution you.



my web blog - www.lastlongerinbedpillsus.com/can-alcohol-cause-Premature-ejaculation.html
Quote
 
 
0 #263 Guest 2016-04-21 19:43
Usually I don't read article on blogs, however I would like to say that this write-up very compelled me to
check out and do so! Your writing style has been amazed me.
Thanks, very great article.

Here is my blog post - Trim Garcinia Cambogia
healthy weight loss
Quote
 
 
0 #262 Guest 2016-04-21 17:17
I really like what you guys are up too. This sort of clever work and exposure!
Keep up the terrific works guys I've added you guys to my personal blogroll.


Review my blog post: Elysian Moisturizing Cream
Quote
 
 
0 #261 Guest 2016-04-21 06:34
is the main food staple of river communities in the Amazon estuary,
' says the agronomist Oscar Nogueira. Viagra moreover
comprises of various non-active elements: indigo carmine aluminum paint,
magnesium stearate, and so forth. "This sense of entitlement I don't understand because I wasn't raised that way.

Also visit my page: www.generiqueviagrafr.fr/recherche-sur-le-viagra
Quote
 
 
0 #260 Guest 2016-04-20 04:34
Hi there everyone, it's my first pay a quiick viisit at this site, and post is in fact fruitful
designed for me, kep uup posting such articles.

Jangan lupa untfuk Kunjngi site Aku buat dapat Informasi lebih komplit
mengenai Grosir tas LV ori Leather.
Thanks ya
Quote
 
 
0 #259 Guest 2016-04-19 20:11
Occasionally you may also lie down which will be
convenient. There are a range of all natural herbal
remedies that men could be using. Buy Viagra Online, Erectile dysfunction is becoming common problem these
days so if you are facing such difficulties then please contact your doctor.


my blog ... www.cialis20mgfr.fr/acheter-tadalafil-20-mg/
Quote
 
 
0 #258 Guest 2016-04-19 08:05
I'm not sure exactly why but this website is loading very slow for me.
Is anyone else having this problem or is it a problem on my end?
I'll check back later on and see if the problem still exists.



Also visit my blog post ... Free e liquid
Quote
 
 
0 #257 Guest 2016-04-18 20:39
I just couldn't leave your site prior to suggesting that I really loved
the standard info an individual provide in your guests?
Is gonna be back frequently to check up on new posts

Feel free to visit my site; mattress
reviews
Quote
 
 
0 #256 Guest 2016-04-17 13:35
I loved ɑs much as you will receive carried out rіght һere.
The skegch is tasteful, ʏⲟur authored subject matter stylish.
nonetҺeless, үou command get gоt an shakiness օver that yߋu wish be delivering thе foⅼlowing.
unmwell unquestionably cօme more formerly aɡain aѕ ᥱxactly the
ѕame nearly а lot often inside casе you shield this increase.


my webpage ... leather weekender (www.f010.com/space-uid-158483.html)
Quote
 
 
0 #255 Guest 2016-04-13 13:40
I don't even know how I stopped up right here, but I believed this submit was good.
I don't recognize who you might be but certainly you are going to a well-known blogger for those
who are not already. Cheers!

Here is my blog post ... proven antiaging
Quote
 
 
0 #254 Guest 2016-04-12 00:37
First of all I want to say awesome blog! I had a
quick question in which I'd like to ask if you do
not mind. I was curious to know how you center yourself and clear your
mind before writing. I have had a tough time clearing
my thoughts in getting my ideas out there. I do take pleasure in writing but it just seems like the
first 10 to 15 minutes are usually lost simply just trying to figure out
how to begin. Any recommendations or tips?
Thanks!

Look into my page - Allegro Anti Aging Cream
Quote
 
 
0 #253 Guest 2016-04-11 22:39
What's up, constantly i used to check web site posts here in the early hours in the morning,
for thhe reason that i love to gain knowledge of more and more.



Feel free to visit my web page; generic
cialis in canada
Quote
 

Add comment


Security code
Refresh