Abort a Git Merge

余生颓废 提交于 2019-12-02 16:55:16

as long as you did not commit you can type

git merge --abort

just as the command line suggested.

MLY

If you do "git status" while having a merge conflict, the first thing git shows you is how to abort the merge.

Truth be told there are many, many resources explaining how to do this already out on the web:

Git: how to reverse-merge a commit?

Git: how to reverse-merge a commit?

https://git-scm.com/blog/2010/03/02/undoing-merges.html

So I guess I'll just summarize some of these:

  1. git revert <merge commit hash>
    This creates an extra "revert" commit saying you undid a merge

  2. git reset --hard <commit hash *before* the merge>
    This reset history to before you did the merge. If you have commits after the merge you will need to cherry-pick them on to afterwards.

But honestly this guide here is better than anything I can explain, with diagrams! :)

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