Skip to content

Instantly share code, notes, and snippets.

View NehaP09's full-sized avatar

Neha Uppal NehaP09

  • Berlin, Germany
View GitHub Profile
@NehaP09
NehaP09 / Recover_deleted_remote_branch.txt
Created February 3, 2022 16:06
Recover deleted remote branch
I accidentally deleted a git branch from both local and remote and also refreshed the page so the "recover" option was gone.
I didn't lose any code, since I had a backup copy.
But I did lose the commit history.
I was left with all code changes from all 16 commits in a folder.
This is what I did to recover the deleted local and dev branch:
1. git checkout master
2. git reflog
3. obtain the SHA of the top/latest commit on the deleted branch
4. get out of the reflog mode