Git Recover a deleted branch


To recover a deleted branch you need to find the commit which was the head of your deleted branch by running

git reflog

You can then recreate the branch by running

git checkout -b <branch-name> <sha1-of-commit>

You will not be able to recover deleted branches if git's garbage collector deleted dangling commits - those without refs. Always have a backup of your repository, especially when you work in a small team / proprietary project