Git: how to undo merge during rebase

我们两清 提交于 2019-12-24 11:37:01

问题


I've made a pull with rebase:

git pull --rebase

After two commits were successfully applied I started applying the third one. It the middle of this I realized that I did it wrong and it would be good to undo it. Of course I can do git

rebase --abort

but then I'll loose all the work I've done (two applied commits).

Is there any way to undo the process of applying current commit during rebase and start merging again?


回答1:


You can do a

git rebase --skip

(perhaps multiple times)

That way, your applied commits will be saved. However at that point your third commit will be hidden, so follow up with:

git branch old-commit ORIG_HEAD

to have access to your other (third an following) commits.

For finishing touch, you could do

git checkout old-commit && git rebase --interactive HEAD...master

and remove the successfully rebased commits.



来源:https://stackoverflow.com/questions/22562219/git-how-to-undo-merge-during-rebase

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