git本地分支删除,代码没了!怎么恢复!亲测有效~

简单几步~

找到存放项目所在的目录,Git Bash Here ,出现git的窗口。

(1) 输入 git log -g ,找回之前提交的commit,并记下commit_id。(可以通过键盘上下键翻看所有的记录)

(2) git branch newbranch commit_id。

(3) 切换到newbranch分支,检查文件是否存在。


原文:https://blog.csdn.net/qq_36433725/article/details/83011363