Updated Jun 18, 2026

Git Disaster Recovery - Getting Back What You Thought You Lost

This is the guide the others kept promising. Something has gone genuinely wrong - a reset --hard ate your afternoon, a rebase turned into a wall of conflicts, you pushed a commit that never should have left your laptop. Your heart rate is up. Let's bring it down.

Here is the single most important fact in this entire guide, and you can lean your whole weight on it:

Git almost never destroys your commits. It loses track of them. A commit you "deleted" is, in the vast majority of cases, still sitting in the repository - Git just moved a label off it. Recovery is usually a matter of finding it again, not resurrecting it from nothing.

Once you believe that - and by the end of Phase 1 you will, because you'll do it yourself - these situations stop being catastrophes and become procedures. That's the whole shift this guide delivers: from panic to procedure.

⏭️ This is the advanced guide. It assumes you're fluent with commits, branches, HEAD, reset, merging, and remotes. If any of those are shaky, the earlier guides build the foundation: Git From ZeroGit, Explained Like You're a HumanGit With Other People.

How to read this

  • On fire right now? Go straight to the recovery cheat-card in Phase 1 - the reflog rescues most "I lost it" disasters, and it's the first thing you'll reach for.
  • Want to wield the sharp tools safely? Read in order. Phase 1 is the safety net that makes Phases 2 and 3 safe to attempt.

The phases

  1. The Reflog - Your Safety Net - why almost nothing is truly gone, and how to recover "lost" commits, a bad reset --hard, and even a deleted branch.
  2. Rebase Without Fear - what rebase really does, cleaning up history before a PR, the one rule that keeps it safe, and rescuing a rebase gone wrong.
  3. Undoing What You've Already Pushed - the safe public undo (revert), when rewriting pushed history is OK, and how to do it without clobbering your team.

This is the final rung of the Git track. After it, you'll have the complete picture - from your first commit to rescuing history under pressure - and very little in Git will be able to genuinely scare you.