问题:
This question already has an answer here: 这个问题在这里已有答案:
- How do I revert a Git repository to a previous commit? 如何将Git存储库还原为先前的提交? 41 answers 41个答案
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
来源:oschina
链接:https://my.oschina.net/stackoom/blog/3275721