How to recover a deleted branch that was not merged?

Ask a question+

Is there any command, which will recover a deleted branch, which has not merged? Any suggestions?

Ala 130
add comment

2 Answers


You can do it with git-reflog command
Read more about this comand : https://www.w3docs.com/learn-git/git-reflog.html#Recovering

Alvard 930
add comment

ou can do it in one step:

git checkout -b <branch> <sha>

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

add comment

Your Answer