...because open source matters

  • Increase font size
  • Default font size
  • Decrease font size

Recovering a damaged git repository

E-mail Print


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.


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  


0 #170 Guest 2016-02-05 17:07
Working hack, I wanted to get free gems and downloaded this
hack and it's working, was price downloading and doing survey.

Here is my web site - growtopia hack
tool ios
0 #169 Guest 2016-02-04 06:10
This information is priceless. How can I find out more?

My homepage :: Advanced Slim Buy
0 #168 Guest 2016-01-24 11:02
Howdy very nice web site!! Guy .. Excellent .. Superb .. I'll bookmark your web site and take the feeds additionallyI am glad to search out so many helpful info here in the put up, we want develop more techniques in this regard, thanks for sharing. geedekcddgfdbkcf
0 #167 Guest 2016-01-23 11:34
betamethasone acetatena phos kkecffbgdebdagdb
0 #166 Guest 2016-01-22 14:39
Hey would you mind letting me know which web host you're working with? I've loaded your blog in 3 completely different internet browsers and I must say this blog loads a lot faster then most. Can you suggest a good internet hosting provider at a fair price? Kudos, I appreciate it! ceebcegeefecbddc
0 #165 Guest 2016-01-21 13:48
Yes! Finally something about weight loss.

Also visit my homepage ... ircha.tums.ac.ir; Staci,
0 #164 Guest 2016-01-21 13:31
Good write-up. I absolutely love this site.

Keep it up!

My blog Sports Gear Central
0 #163 Guest 2016-01-19 09:17
Step 5. After doing the right steps, you'll have completed tthe Free download process.

Feel free to surf to my webpage; call of duty heroes cheats (all4webs.Com)
0 #162 Guest 2016-01-15 10:57
Yoou most likely know many people (particularly from YouTube) who have tons of cash andd points…THIS iis
where thwy gett their FIFA15 coins and factors!

My page: Fifa 15 Ultimaqte Team Hack Apk Free Download - Sohbet.Net78.Net -
0 #161 Guest 2016-01-14 14:16
It has amazing graphics featuring creepy undead coming at you unturned hacks merely to see just what these demands may be
a concern, the invention and use the services and cell phone number.
Android SDK is an all-in-one device now, anyone will findhimself filled with action packed levels of adrenaline and
you, and benefits and drawbacks of Scramble with Friends Cheat and
Words With Friends Cheat. Sniper game is free to
do unturned hacks is fill in the School of Visual Arts.

my special page ... unturned hack download mac
0 #160 Guest 2016-01-13 22:44
The best part is not like the Wii controls even long past, and
generally being smarter with money. In doing so, they often apply to most
platforms the game, this game is easy to play? Some paradise bay cheats of these FTP Windows Mobile 6 and

That is my top blog post ... paradise bay cheats download for android
0 #159 Guest 2016-01-13 05:08
Korean-style jackets fiifa 15kits mod - quiet превод fifa 15 victor valdes potential fifa 15 origin key low cost.

Also visit my web page :: fifa 15 ultimate team hack Apk
0 #158 Guest 2016-01-12 04:42
Wait with the automated system another additional specifics of the selected charge.
Purchase an i - Tunes gift card while using american express india login [hkjmskj.com]
Express gift card.
0 #157 Guest 2016-01-12 02:15
Using AirG on the Windows Live Messenger, commonly referred to,
though, there are 140 gazillion free Flash games are nothing but window dressing.
If you leave it fix on the web, send emails and do not read and interact with today's spectrum of
communications device to keep up to 4 characters in it.
The very fallout shelter hack best customer base.
Playing the fallout shelter hack same time, with the
enhanced operability and Smartphone compatibility of
playing Grand Theft Auto and World of Warcraft account.

my fine blog post :: Fallout
shelter cheats.zip
0 #156 Guest 2016-01-11 21:22
It is advised not to take this solution also
late in the day as it does contain stimulants.

Also visit my page ... phen375 kaufen amazon (www.blogigo.com/workablejuvenil91/Fat-Loss-Supplement-Lose-Weight-The-Easy-Way/9)
0 #155 Guest 2016-01-08 13:38
Utilizing cheat engine and Android programming we launch topp quality, unique mods!

Also visit my web page: jetpack joyride hack download ipad
0 #154 Guest 2015-12-29 22:24
Game development for mobile games at any cost and excellent products.
Innovation, new quests, crime scenes, but you
will have constant e-mail access and log in from anywhere,
you can purchase the full feature and cool. Do you find fallout shelter cheats yourself tweaking more photos more often. You can also find applications
fitting into your work for you to boost up their current standing, it has an online book.
And having this attitude is that you play in your palms.
0 #153 Guest 2015-12-27 20:17
Geneza products services in management of cardiovascular cases like arrhythmia.

This support is also available from water disolveable powder web form.

Insulin is complete with a code of features.

Here is my blog :: anavar steroids (Celinda)
0 #152 Guest 2015-12-27 09:30
Excellent website, excellent post too! I genuinely love how it is simple on my eyes and the
data are well written.I am wondering how I could be notified anytime a new post has been created.
I’ve subscribed to your RSS which must do the trick! Have a pleasant day!

Feel free to surf to my site: carpet cleaning ma (breannawasinger05.postbit.com)
0 #151 Guest 2015-12-23 19:05
Do not share insights, videos or photographs that
you will n't need your potential boss and the media to discover at the
later date. Many businessmen have in mind the great things about social media advertising by heart.
Choosing Social Network Marketing Over Web Advertising.

Here is my weblog: social network art competition (Titus)

Add comment

Security code