How can I restore a local branch after deleting it?

霸气de小男生 提交于 2019-12-08 09:56:43

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!