What should I do when git revert aborts with an error message?

一个人想着一个人 提交于 2019-12-17 16:24:32

问题


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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/6084483/what-should-i-do-when-git-revert-aborts-with-an-error-message

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!