Cancel git merge but keep local changes

后端 未结 4 988
灰色年华
灰色年华 2021-02-20 05:40

I started a git merge, but made local changes that I want to keep. I no longer want to merge, and instead continue to work on the local changes. How do I do this?

4条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-20 06:06

    First, copy the folder you're working in in case something bad happens. Git is usually pretty bulletproof, but if you start using git reset --hard, it's possible for bad things to happen.

    Then, do a git commit --patch, picking only the changes that you want to keep and leaving everything that the merge did. Once you've committed those changes, do a git reset --hard, and the merge should be gone, but your changes should still be there.

提交回复
热议问题