恢复到特定的 sha 或提交

发布于 2024-12-17 01:15:59 字数 493 浏览 0 评论 0原文

我正在尝试恢复到特定的提交( 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

极致的悲 2024-12-24 01:16:00

您想要执行的操作:

 git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d

这会将您“重置”到指定的提交。

git revert 只是创建一个新的提交,它会恢复该提交的更改,这可能不是您想要的。

You want to do:

 git reset 3d5575f8e4c97ddab8ad5d540fee4664c04db75d

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.

深海蓝天 2024-12-24 01:15:59

我想你想使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文