Search code examples
git-rebase

How to cancel a rebase after it has successfully completed : GIT


I need to come to the state before rebase.

The following command gives the error, which makes sense. My rebasing was successful.

git rebase --abort
No rebase in progress?

Any idea?


Solution

  • In the general case, if you completed your rebase, then your branch is now sitting on a new base of one or more commits, and you may have reworked some of the commits which were already on the branch, as you reapplied them.

    One possible fix here would be to just reset your branch to the remote tracking branch:

    git reset --hard origin/feature
    

    Note that this option would only make sense if you have not made any new commits since you last pulled. Assuming this, the tracking branch would serve as a sort of backup of the branch before you did the unwanted rebase.