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 #396 Guest 2016-09-29 05:38
We give the best deals of any computer shop for PC, laptop repair Woodland Hills, Mac repair and Data recovery.
Quote
 
 
0 #395 Guest 2016-09-14 02:46
While you arre using cell phones, youu can even use
hotspot shiel VPN for complete security. Some service
providers will supply you with everything thaat is needed to set up a connection to their CCcam server.
At this point, thhe receiver is contacting the server for decryption keys and the CCcam software iss the one
using those keys to unlock that picture forr the
user to watch.

Also visit my web pawge ... newcamd Server 2015
Quote
 
 
0 #394 Guest 2016-09-12 02:40
They can also provide you the total security systems installation for your residential or commercial purposes.
In addition, you might need to have an electronic key replaced and a locksmith can also perform this service.

A locksmith Apache service provider will be able to help you install a
wide variety of locks and security devices that can improve the security of
your house.

My web page :: עבודות מתכת בכפר סבא
Quote
 
 
0 #393 Guest 2016-09-11 00:49
Nous devions attaquer l'ennemi; c'est lui qui nous attaque, encourage par
les avantages qu'il vient d'obtenir dans la nuit:
mais il ne peut parvenir a occuper le village de Clacy, ou la
division Charpentier fait la plus belle contenance.



Look at my weblog :: magasin bio en ligne
Quote
 
 
0 #392 Guest 2016-09-10 04:12
If you don't mind paying a little bit additional, then Joint Pain Relief
Codes could be definitely worth the price - especially for those who're affected by power joint pain daily.


My webpage joint pain relief codes pdf
Quote
 
 
0 #391 Guest 2016-09-09 11:08
Attractive section of content. I just stumbled upon your web site and hotels in albuquerque
new mexico near i-40
accession capital to assert
that I get actually loved account your blog posts.
Any way I will be subscribing on your feeds
and even I success you get right of entry to
consistently fast.
Quote
 
 
0 #390 Guest 2016-09-07 03:24
It's an awesome article designed for all the web viewers; they will
take advantage from it I am sure.

Look into my web blog; katleriokortos.lt
Quote
 
 
0 #389 Guest 2016-09-05 21:14
Sweet blog! I found itt while browsing on Yahoo News.
Do you have any suggestions on how tto get listed in Yahoo News?
I've been trying for a while but I never seem to get there!

Thank you

Feell free to visit my blog post; loading...
Quote
 
 
0 #388 Guest 2016-09-05 10:27
This web site certainly has all of the info I wanted concerning
this subject and didn't know who to ask.

my site project free
tv
Quote
 
 
0 #387 Guest 2016-09-04 16:13
Hello, everything is going fine here and ofcourse every one is sharing data, that's in fact fine, keep
up writing.

Also visit my weblog ... עמדות רישום
ממוחשבות
Quote
 
 
0 #386 Guest 2016-09-04 15:18
Hi, Neаt post. There's a problem wiҺ your web sіte in internet explorer, culd cɦeck this?
IE still is the market chief and a larve component to other people աill omіt your
great writing due to thіs problem.

My site :: seo for small
bսsiness
Quote
 
 
0 #385 Guest 2016-09-01 07:53
It's very easy to find out any matter on net as compared to textbooks, as I found this post at this web page.


Feel free to visit my weblog - movietubenow
Quote
 
 
0 #384 Guest 2016-08-31 02:03
Good replies in return of this issue with firm arguments and telling all regarding that.



Review my web-site - psychiatric Help
Quote
 
 
0 #383 Guest 2016-08-30 18:44
What i do not understood is in reality how you are now not
really much more neatly-favored than you may be right now.
You're very intelligent. You understand thus significantly in terms of this matter, made me individually imagine it from numerous varied angles.
Its like women and men don't seem to be involved unless it is one
thing to do with Girl gaga! Your individual stuffs great.
At all times deal with it up!

my website house
cleanout Services
Quote
 
 
0 #382 Guest 2016-08-28 04:36
Victor worked for Aspen Commercial Security and has been continually grateful
for the knowledge they have shared with him. Usually a security code is used to open these kinds of locks.
With a very good background to its credit, you
will surely have a rewarding and ingenuous experience with a
locksmith.

Here is my website: מנעולן
מדרג
Quote
 
 
0 #381 Guest 2016-08-22 11:00
Ꮇʏ family alwaʏs ssay tҺɑt I am wasting mу time herе at web, exϲept I know I am getting know-how every day by
reading sᥙch nice posts.

Aⅼso visit mу site Anello Bag Offer (Merissa)
Quote
 
 
0 #380 Guest 2016-08-21 08:50
My brother recommended I would possibly like this blog.
He was once entirely right. This publish actually made my
day. You can not consider just how much time I had spent for this info!
Thank you!

Also visit my web page: movie
tube
Quote
 
 
0 #379 Guest 2016-08-21 02:05
Wonderful blog! I found it while searching on Yahoo News.
Do you havve any tips on how to get listed in Yahoo News?
I've been trying for a while but I never seem to get there!
Thanks

Herre is my web site; hello
Quote
 
 
0 #378 Guest 2016-08-20 14:13
First of all I would like to say wonderful blog!
I had a quick question that I'd like to ask if you don't
mind. I was interested to know how you center yourself and
clear your thoughts before writing. I have had trouble 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 wasted simply just trying to figure out how to begin. Any ideas
or hints? Appreciate it!

Feel free to surf to my web page :: dating in kent
Quote
 
 
0 #377 Guest 2016-08-19 15:38
Good day! Do you know if they make any plugins to help with Search Engine Optimization? I'm
trying to get my blog to rank for some targeted keywords but I'm
not seeing very good gains. If you know of any please share.
Many thanks!

my web page: movietubenow
Quote
 

Add comment


Security code
Refresh