简体   繁体   English

如何撤消对Git所做的更改?

[英]How do I undo committed changes on Git?

I'm trying to restore my stable tag by removing the most recent commit. 我正在尝试通过删除最近的提交来恢复我的稳定标签。 I ran this command: 我运行了以下命令:

git revert e64218b5d415419043002e67115f81bff05bde0e

This appeared: 这出现了:

    error: Your local changes would be overwritten by revert.
    hint: Commit your changes or stash them to proceed.
    fatal: revert failed

I left this message and closed the file. 我留下了这则消息并关闭了文件。 After verifying that crazy.html was gone, I took a look at my history with git log --oneline 确认crazy.html消失之后,我使用git log --oneline查看了我的历史git log --oneline

e64218b Add a crazzzy experiment
2d0b4b6 Add navigation links
35a79d5 Create blue and orange pages
f72749b Create index page

Why didn't Git figure out how to undo the changes that it contained? Git为什么不弄清楚如何撤消其中包含的更改? Why didn't Git tack on another commit with the resulting content? Git为什么不对结果内容进行另一次提交?

Edit - Git status shows: 编辑-Git状态显示:

On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)

deleted:    crazy.html

您可以执行git stashgit pullgit stash pop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM