Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

25
  • 2
    Hmm, my laptop died during a git operation (SparkleShare was trying to commit my notes as it died) and after that the repo was corrupted in this way. I followed your steps up till 6 but it seems like the last several commits were actually supposed to be part of the empty object files that I deleted? In fact the last 3 commits were basically completely broken so I guess there was nothing I could do. Luckily I don't actually need the individual commits from SparkleShare and I can just copy over the dirty file from one machine to another and merge. Commented Apr 22, 2013 at 20:41
  • 5
    Thanks, I learned a lot about some of the git functionality whilst also saving my bacon on an important commit! Coincidentally it was also because of low battery on the laptop. Commented Jul 2, 2014 at 10:34
  • 6
    can we give this man a Nobel Prize or something? I made a mess when my removable device got removed unexpectedly, and I'm pleasantly astonished that I was able to clean it up with this recipe. you ROCK! Commented Apr 22, 2016 at 0:50
  • 2
    If the error persists after step 11 (for git fsck --name-object) like git broken link from tree 61d013* to blob, it might be required to follow the instruction on stackoverflow.com/a/11959590/2062965 - it solved the issue for me. Commented Sep 7, 2018 at 11:16
  • 2
    May I propose a step 13 with cd ~; mkdir recovered; cd recovered; git init; git remote add damaged path/to/damaged; git fetch damaged. After these step, some of the power loss during git-rebase related damage was still causing issues. But with a cleaner repository, you lose dangling objects, which may or may not be important (they are common for the Gerrit workflow), but at least all the local branches are restored. Doing an extra step to copy the untracked and ignored files from the damaged repository to the new one is also potentially helpful. But really, thanks for this! Commented Mar 13, 2019 at 18:32