当 git revert 中止并显示错误消息时,我该怎么办?
好的,所以当我尝试恢复提交(使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您必须解决冲突,用
git add
或git rm
和git commit
标记它们。提交尚未完成,在
git revert
之后 - 如果您看到 .git/MERGE_MSG,您将看到类似以下内容:因此,一旦您解决了合并并执行了 git commit,您将看到来自 MERGE_MSG 文件的消息,您可以提交并完成恢复。
Yes you will have to resolve the conflicts, mark them as so with
git add
orgit rm
andgit commit
The commit is not done yet, after the
git revert
- if you see .git/MERGE_MSG, you will see something like: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.如果您想删除所有冲突并删除已完成的导致中止错误的恢复,您可以使用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.