restore - git reset --hard HEAD^

断了今生、忘了曾经 提交于 2019-12-03 11:05:32

Use the reflog to recover the sha1 of the previous HEAD. In particular, the article reflog, your safety net will be particularly relevant to you. From that article:

The most common usage of this command is that you’ve just done a git reset and moved your HEAD back a few commits. But oops, you need that bit of code you left in the second commit. Crap. Now what?

Once you have found the sha1 of the commit you want to go back to, use something like:

git reset --hard 0a1b2c

Run git reset --hard HEAD@{1} if you just committed your code and you want to undo that.

See Section called "Ordinal Spec" at http://book.git-scm.com/4_git_treeishes.html

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