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 #80 Guest 2015-07-15 15:32
Spot on with this write-up, I honestly believe that this web site needs far more attention. I'll probably be
returning to see more, thanks for the info!


Here is my blog post cialis
Quote
 
 
0 #79 Guest 2015-07-15 07:42
Nice post. I learn something new and challenging on websites I stumbleupon every day.
It's always helpful to read through content from other
authors and practice a little something from other sites.


Feel free to visit my homepage cialis
Quote
 
 
0 #78 Guest 2015-07-13 01:16
I like reading through a post that can make people think. Also, thanks for permitting me to comment!


Here is my web page ... canadian pharmacy
Quote
 
 
0 #77 Guest 2015-07-08 15:17
I have read so many posts about the blogger lovers however this paragraph is
really a fastidious post, keep it up.

My webpage :: Cialis
Quote
 
 
0 #76 Guest 2015-07-07 08:47
What's up, just wanted to say, I enjoyed this blog post.

It was inspiring. Keep on posting!

My website; Cialis
Quote
 
 
0 #75 Guest 2015-07-06 05:59
Hey I know this is off topic but I was wondering if
you knew of any widgets I could add to my blog that automatically
tweet my newest twitter updates. I've been looking for a plug-in like this for quite some time and was hoping maybe you would have
some experience with something like this. Please let me know if you run into anything.
I truly enjoy reading your blog and I look forward to your new updates.


my web page :: cialis
Quote
 
 
0 #74 Guest 2015-07-04 13:59
Hi there! I know this is kinda off topic nevertheless
I'd figured I'd ask. Would you be interested in trading links or maybe guest authoring
a blog article or vice-versa? My website discusses a lot of the same topics as yours and I believe we could greatly benefit
from each other. If you're interested feel free to send me an email.
I look forward to hearing from you! Superb blog
by the way!

Here is my page; Cialis
Quote
 
 
0 #73 Guest 2015-07-01 18:26
Having read this I thought it was extremely enlightening.

I appreciate you taking the time and energy to put this information together.
I once again find myself spending a lot of time both reading
and leaving comments. But so what, it was still worth
it!

Feel free to visit my blog: cialis
Quote
 
 
0 #72 Guest 2015-06-29 17:32
I seriously love your site.. Pleasant colors & theme. Did you
develop this amazing site yourself? Please reply back as I'm planning
to create my own personal website and would love to learn where you got this from or what the theme is named.
Appreciate it!

Also visit my web blog; www.canadiandrugstore.com
Quote
 
 
0 #71 Guest 2015-06-28 01:00
Does your site have a contact page? I'm having trouble
locating it but, I'd like to send you an e-mail.
I've got some recommendations for your blog you might be interested in hearing.
Either way, great website and I look forward to seeing it improve over time.


My site; sikis izle
Quote
 
 
0 #70 Guest 2015-06-24 11:09
I enjoy what you guys are up too. This sort of clever work and coverage!
Keep up the amazing works guys I've incorporated you guys how
to boost followers on instagram (Lukas) blogroll.
Quote
 
 
0 #69 Guest 2015-06-23 17:18
Hey there! I just wanted to ask if you ever have any problems with hackers?
My last blog (wordpress) was hacked and I ended up losing many
months of hard work due to no data backup. Do you have any solutions to protect against hackers?


Also visit my weblog; buy instagram followers
Quote
 
 
0 #68 Guest 2015-06-20 08:24
I am really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. Your post is most good looking and so nice.

Search on google xnxx go to www.xnxx247.com

Search on google porntube go to www.tube17.com

Search on google xnxx go to www.xnxxbig.net

Search on google xhamster go to www.largexhamster.com

Search on google xnxx go to www.xnxx365.com
Quote
 
 
0 #67 Guest 2015-06-18 18:45
Oh my goodness! Awesome article dude! Thanks, However I am encountering
difficulties with your RSS. I don't know the reason why
I cannot join it. Is there anybody else getting identical RSS issues?
Anyone that knows the solution will you kindly respond?
Thanks!!

My weblog canadian pharmacies
shipping to usa
Quote
 
 
0 #66 Guest 2015-06-18 17:50
Woah! I'm really digging the template/theme of this site.
It's simple, yet effective. A lot of times it's difficult to get that "perfect balance" between usability and
visual appeal. I must say you have done a very good job with this.
Additionally, the blog loads super quick for me on Chrome.
Superb Blog!

Feel free to visit my site - canadian pharmacies shipping to usa
Quote
 
 
0 #65 Guest 2015-06-16 01:20
This is my first time visit at here and i am actually happy to read everthing at single place.


My web site; gay pornolari
Quote
 
 
0 #64 Guest 2015-06-15 10:29
Nice post. I was checking constantly this blog and I am impressed!

Very useful information particularly the last part :) I care for such information a lot.
I was looking for this certain info for a long time.
Thank you and best of luck.

Here is my homepage :: prednisone
Quote
 
 
0 #63 Guest 2015-06-15 04:53
My spouse and I stumbled over here coming from a different web address and thought I may as well check things out.
I like what I see so now i am following you.
Look forward to going over your web page for a second time.



Here is my web page - prednisone
Quote
 
 
0 #62 Guest 2015-06-12 16:47
My partner and I absolutely love your blog and find most of your post's to be precisely what I'm looking for.
can you offer guest writers to write content for you personally?

I wouldn't mind publishing a post or elaborating on a lot of
the subjects you write in relation to here. Again, awesome website!


Feel free to visit my website :: prednisone
Quote
 
 
0 #61 Guest 2015-06-12 02:24
31 Thinking that a porno movie has anything to do with real life.
The hint of what's to come is often more erotic than diving
straight in there. The idea of a special suffix--a "top level domain"--dedicated to such material would allow such web sites to be easily screened by a simple browser function, a command which required a password to access files with that ending.


Here is my weblog - gerçek liseli porno Izle
Quote
 

Add comment


Security code
Refresh