如何使用'git reset --hard HEAD'恢复到之前的提交? [重复]

社会主义新天地 提交于 2020-04-20 05:35:15

问题:

This question already has an answer here: 这个问题在这里已有答案:

I know that Git tracks changes I make to my application, and it holds on to them until I commit the changes, but here's where I'm hung up: 我知道Git会跟踪我对我的应用程序所做的更改,并且它会保留给他们,直到我提交更改,但这里是我挂断的地方:

When I want to revert to a previous commit I use: 当我想恢复到之前的提交时,我使用:

git reset --hard HEAD

And Git returns: 而Git回归:

HEAD is now at 820f417 micro

How do I then revert the files on my hard drive back to that previous commit? 然后,我如何将硬盘上的文件恢复为之前的提交?

My next steps were: 我接下来的步骤是:

git add .
git commit -m "revert"

But none of the files have changed on my hard drive... 但我的硬盘上没有任何文件发生变化......

What am I doing right/wrong? 我在做什么是对还是错?


解决方案:

参考一: https://stackoom.com/question/dywo/如何使用-git-reset-hard-HEAD-恢复到之前的提交-重复
参考二: https://oldbug.net/q/dywo/How-do-I-use-git-reset-hard-HEAD-to-revert-to-a-previous-commit-duplicate
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!