Abort a Git Merge

前端 未结 3 1957
挽巷
挽巷 2021-01-30 06:10

I am working on a project using Git as the VCS. I got a branch xyz cut from the mainline branch of master. After working for a while, I committed my code and took a

3条回答
  •  暖寄归人
    2021-01-30 06:21

    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?

    Undoing Merges, from Git's blog (retrieved from archive.org's Wayback Machine)

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

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

    2. git reset --hard
      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! :)

提交回复
热议问题