.GIT 中的回滚提交
我刚刚在实时服务器上进行了一些我还不想要的更改。我需要回滚到最后一次拉取之前的先前版本。
但我不确定正确的命令或如何获取我想要回滚到的上一个提交的哈希值。非常感谢任何帮助。
我设法使用以下命令回滚头部,
git reset --hard HEAD^
这使我的头部回到了正确的位置。
但它似乎仍然拉下了服务器上的更改,我现在需要删除这些文件。
我也刚刚尝试过,
git clean -f
我认为阅读后会删除不需要的添加代码和文件。似乎已删除文件,但未删除现有文件中的代码。
I've just pulled on the live server some changes that I don't want on there yet. I need to rollback to the previous version before the last pull.
But i'm not sure of the correct command or how to get the hash for the previous commit that I want to rollback to. Any help much appreciated.
I managed to rollback the head with the following command
git reset --hard HEAD^
Which put my head back to the right point.
But it still appears to have pulled down the changes on the server and I need to now remove the files.
I also have just tried
git clean -f
Which I thought from reading would remove the unwanted added code and files. Seems to have removed the files, but not the code in existing files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
git reset --hard 应该已将您的工作区重新同步到您回滚到的先前提交,那么“我现在需要删除文件”到底是什么意思?是的,git 将在 origin/master 中跟踪来自远程服务器的新更改,但这应该不是问题。
git diff
或git status
是否显示差异?如果是这样,git reset HEAD -- .
、git checkout -- .
将恢复所有内容。git reset --hard
should have resynced your workspace to previous commit you rolled back to, so what do you mean by "I need to now remove the files", exactly? Yes, git will have the new change from the remote server tracked in origin/master, but that shouldn't be a problem. Isgit diff
orgit status
showing differences? If so,git reset HEAD -- .
,git checkout -- .
will revert everything.