← back to diagnosis

deleted a branch

caution

Recover a branch you accidentally deleted locally or remotely.

Find the last commit on the deleted branch:

$ git reflog

Recreate the branch at that commit:

$ git branch <branch-name> <hash>

The commits still exist — deleting a branch only removes the pointer. The reflog will show you where it was.

If you still have the branch locally:

$ git push origin <branch-name>

If not, check if a teammate has it, or look at the reflog on the server (GitHub shows recently deleted branches in the PR UI).