This is a two-way situation.
The first kind you've quit terminal
Git reflog See your last commit SHA1 value
<sha1>
You can create a branch based on your SHA1 value, and this commit you can choose to delete the commit of the branch operation SHA1
The second case does not exit terminal
user@MY-PC /C/MyRepo (master)$ git branch -D master2Deleted130d7ba). ThisSHA1 we need to restore it!user@MY-PC /C/MyRepo (master)$ 130d7ba
When you delete a branch, git branch-d will have a SHA1 value behind it, so you can restore your branch with this SHA1 value.
This time input
git branch 你的分支名 SHA1值
Then you can restore the branch based on your SHA1, the name of the branch is "your branch name"
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Git Undo Branch Delete operation (git delete branch undo)