Reputation: 93
So I managed to perform a rebase and pushed the changes to Gitlab but now I am getting errors and would like to cancel the whole rebase and go back to where I started. I am working on a "feature-branch" and I did the rebase to "develop" branch.
What I did was:
So now both my local branch and the remote branch contains the changes from the rebase. Is there anyway I could cancel the whole rebase and push -f and try to do it again? Thanks!
Upvotes: 1
Views: 1669
Reputation: 4221
You can find the commit on the branch before the rebase happened, then reset it back - (git log or git reflog will help that). Also GitLab has a network tab which should allow you to see this easily.
example of git reflog as that one will probably be the easiest:
git reflog feature-branch
The above will give you some output like:
73d836b feature-branch@{0}: rebase finished: feature-branch onto e806e41f1fe22624e6546abd65c332c934214891
129e6d3 feature-branch@{1}: commit: Commit message
Get the commit ref from the above output (pick the point where the latest good commit was)
git reset --hard {commitRef}
git push -f // this will push your branch back to how it was before rebase
Upvotes: 3
Reputation: 96
you could check out git reflog https://git-scm.com/docs/git-reflog
git reflog feature-branch
and then find the latest good commit and then
git reset -- hard 129e6d3
where that number is the commit ref
EDIT:
after a google search, I found this, https://medium.com/@shreyaWhiz/how-to-undo-a-mistaken-git-rebase-life-saver-2977ff0a0602 which seems like your problem
Upvotes: 5