Ivan Mushketyk
Ivan Mushketyk

Reputation: 8285

Git: how to undo merge during rebase

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?

Upvotes: 1

Views: 353

Answers (1)

blackbuild
blackbuild

Reputation: 5174

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.

Upvotes: 1

Related Questions