Tuomas Toivonen
Tuomas Toivonen

Reputation: 23522

Git, inverted rebase

In git, I accidentally rebased master branch on feature branch. Now I must undo that, but the problem is master doesn't have origin to reset to yet.

How do I undo the rebase of master on feature? And more interestingly, is it possible to actually perform inverted rebase, e.g removing part of history from the branch based on other branch?

Upvotes: 0

Views: 67

Answers (1)

Philippe
Philippe

Reputation: 31237

What you want is probably more an undo than an inverted rebase.

Use git reflog master to find out the sha1 of the commit of master before the rebase and do a git reset --hard.

2 advices before doing that:

  • stash your uncommited changes if you have some before doing it or they could be lost
  • read some doc on the 2 commands to understand what you will do (to be able to get you out of the sheet if you miss something)

Upvotes: 1

Related Questions