当 git revert 中止并显示错误消息时,我该怎么办?

发布于 2024-11-08 13:26:37 字数 398 浏览 5 评论 0原文

好的,所以当我尝试恢复提交(使用 Git)时,有时会遇到错误。我所做的就是

git revert

,它给了我这样的消息:

error: could not revert <commit hash> <commit message>
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

这是否意味着我应该使用 git mergetool 并解决任何冲突?一旦我这样做了,我可以添加/rm然后提交,并且恢复完成吗?

OK, so I'm getting an error sometimes when I try to revert a commit (with Git). All that I do is

git revert <commit hash>

and it gives me this message:

error: could not revert <commit hash> <commit message>
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'

Does this mean that I should use git mergetool and resolve any conflicts? Once I do this can I add/rm and then commit, and the revert is complete?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

╄→承喏 2024-11-15 13:26:37

是的,您必须解决冲突,用 git addgit rmgit commit 标记它们

。提交尚未完成,在 git revert 之后 - 如果您看到 .git/MERGE_MSG,您将看到类似以下内容:

恢复“添加恢复”

这会恢复提交
c1366607f15a8384434948cb0bcbf8ece48bb460。

冲突:

恢复

因此,一旦您解决了合并并执行了 git commit,您将看到来自 MERGE_MSG 文件的消息,您可以提交并完成恢复。

Yes you will have to resolve the conflicts, mark them as so with git add or git rm and git commit

The commit is not done yet, after the git revert - if you see .git/MERGE_MSG, you will see something like:

Revert "adding revert"

This reverts commit
c1366607f15a8384434948cb0bcbf8ece48bb460.

Conflicts:

revert

So once you resolved the merge and do a git commit you will be presented with the message from the MERGE_MSG file and you can commit and that completes the revert.

零度℉ 2024-11-15 13:26:37

如果您想删除所有冲突并删除已完成的导致中止错误的恢复,您可以使用git reset --hard

You can use git reset --hard, if you want to delete all the conflicts and remove the revert you have done for which the abort error arise.

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