恢复到特定的 sha 或提交
我正在尝试恢复到特定的提交( 3d5575f8e4c97ddab8ad5d540fee4664c04db75d ),但是当我这样做时:
git revert 3d5575f8e4c97ddab8ad5d540fee4664c04db75d
它说:
fatal: 'revert' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
我不关心这些更改,并且我也想丢失这些更改,请恢复到该提交(软恢复,不想丢失文件)然后重新拉下更改。我本地的东西全乱了。有什么帮助吗?
I'm trying to revert to a specific commit ( 3d5575f8e4c97ddab8ad5d540fee4664c04db75d ), but when i do:
git revert 3d5575f8e4c97ddab8ad5d540fee4664c04db75d
it says:
fatal: 'revert' is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>' as
appropriate to mark resolution and make a commit, or use 'git commit -a'.
I don't care those changes, and I also want to lose those changes, revert to that commit (soft revert, dont want to lose the files) THEN repull down changes. My local stuff is all messed up. Any help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要执行的操作:
这会将您“重置”到指定的提交。
git revert 只是创建一个新的提交,它会恢复该提交的更改,这可能不是您想要的。
You want to do:
This will "reset" you to the commit specify.
git revert just creates a new commit which reverts the changes of that commit, which is probably not what you want.
我想你想使用 git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d 。这将使您的工作文件保持原样,但将您的 HEAD 重置为您指定的提交。此外,它还应该重置您的索引(清除您选择提交、添加、删除等的文件)。
如果您想删除对工作文件的所有更改,请使用 git reset --hard 3d5575f8e4c97ddab8ad5d540fee4664c04db75d 。
I think you want to use
git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d
. This will keep your working files as is, but reset your HEAD to the commit you specified. Additionally, it should reset your index as well (clears out files you have selected to commit, add, remove, etc).If you want to get rid of all the changes to your working files, use
git reset --hard 3d5575f8e4c97ddab8ad5d540fee4664c04db75d
.