Git//RESCUE

← all rescues

How do I recover a deleted branch in Git?

Run git reflog; the tip of the deleted branch appears near the top (look for checkout: moving from …). Create the branch again from that hash. Unreachable tips stay alive ~30 days.

Do it now:

git reflog
git branch my-branch a1b2c3d

Need more than the one-liner?

This answer covers one scenario out of dozens. The Git Rescue Field Guide collects all 52 recovery situations — resets, rebases, dropped stashes, forced pushes, scrubbed history — each with the exact command and the gotchas that bite afterwards.

More rescues: How do I undo git reset --hard? · How do I recover lost commits after a rebase? · How do I undo a commit I already pushed? · How do I recover a dropped stash? · How do I fix a detached HEAD state in Git? · Can I recover a file I deleted before committing it? · How do I remove a file (or secret) from entire git history? · How do I abort or undo a merge in Git? · How do I find a lost commit when I don't know the hash?