Gitflow
🗑️Deleted a Branch with Unmerged WorkHard+650 XP
Workshop
Scenario reference

Deleted a Branch with Unmerged Work: the situation, step by step

The situation

You ran `git branch -D experiment` to 'clean up', forgetting it had 4 commits that were never merged. PM is asking for that prototype.

The commits still live in the object store. Reflog has the tip SHA.

Hard · 4 steps · +650 XP

What you will practice

This scenario walks through 4 steps, in order:

  1. 01Search the reflog for the deleted branch tip
  2. 02Verify the dangling commit is real
  3. 03Recreate the branch from the recovered hash
  4. 04Switch to it and verify
Reveal the step-by-step commands

Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.

  1. 1. Search the reflog for the deleted branch tip
    git reflog
  2. 2. Verify the dangling commit is real
    git fsck --lost-found
  3. 3. Recreate the branch from the recovered hash
    git branch experiment HEAD@{3}
  4. 4. Switch to it and verify
    git switch experiment

Key takeaway

git branch -D is not destructive immediately — fsck and reflog can rescue you.