当 git revert 中止并显示错误消息时,我该怎么办?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6084483/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What should I do when git revert aborts with an error message?
提问by icnhzabot
OK, so I'm getting an error sometimes when I try to revert a commit (with Git). All that I do is
好的,所以当我尝试恢复提交(使用 Git)时,有时会遇到错误。我所做的就是
git revert <commit hash>
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?
这是否意味着我应该使用git mergetool
并解决任何冲突?一旦我这样做,我可以添加/rm然后提交,并且恢复完成吗?
采纳答案by manojlds
Yes you will have to resolve the conflicts, mark them as so with git add
or git rm
and git commit
是的,您必须解决冲突,用git add
或git rm
和git commit
The commit is not done yet, after the git revert
- if you see .git/MERGE_MSG, you will see something like:
提交尚未完成,在git revert
- 如果您看到 .git/MERGE_MSG 之后,您将看到如下内容:
Revert "adding revert"
This reverts commit c1366607f15a8384434948cb0bcbf8ece48bb460.
Conflicts:
revert
还原“添加还原”
这将恢复提交 c1366607f15a8384434948cb0bcbf8ece48bb460。
冲突:
恢复
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 commit
您将看到来自 MERGE_MSG 文件的消息,您可以提交并完成还原。
回答by ARKhan
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.
您可以使用git reset --hard,如果您想删除所有冲突并删除您已完成的导致中止错误的还原。