问题
I had a branch called my_branch_1
in my local repository, which I deleted.
my_branch_1
was only local; I never pushed it to a remote server.
Is it possible to restore this branch, somehow?
回答1:
Yes, you can see its SHA1 with git reflog.
Then you can re-create it:
git checkout -b my_branch_1 SHA1
You can also have a look at the script (included in a Git distrib): contrib/git-resurrect.sh.
回答2:
VonC has guided you in the correct direction.
But I could not able to stop myself from sharing this wonderful GithubGist of recover git branch.
来源:https://stackoverflow.com/questions/27186883/how-can-i-restore-a-local-branch-after-deleting-it