How to undo merge request with its commits?
First create a new branch keepsafe
to have all those changes still somewhere in case you mess up. This will "copy" the current state locally and save it on the remote also.
git checkout -b keepsafe
git push
Now go back to develop. X
is the number of commits you want to have deleted.
git checkout develop
git reset --hard HEAD~X
git push -f
The will hard reset local develop to the original commit. git push -f
will overwrite the remote branch. All commits will be gone.
Note that GitLab allows the administrator to disable force pushes (git push -f), so if that doesn't work you need to talk to your administrator.
gizyk
Updated on June 19, 2022Comments
-
gizyk almost 2 years
I did a
merge request
to my branchdevelop
on gitlab. Then I realise I had done a huge mistake. I quickly pushed therevert
button, and I thougth It's everything ok, It wasn't. Gitlab made onlyrevert
commit. In the logs there are still commits from source branch. It causes many issues with version. Is it any way, any solution to revert single merge request on gitlab platform and clean branch logs from many commits which are unwanted. I'd like my branch to be like this merge request never had a place.