Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top