I have pushed a commit by mistake to my Gitlab. How can I undo it?

I have pushed a commit by mistake to my Gitlab. How can I undo it?

 
    
     
    
    Easy way is to click the revert button in the merged merge request.
Steps to revert a merge request from UI:
rever-some_sha.2[ Or ]
revert-some_sha locally, add any changes you wanted.Recommendation: Do a periodical rebase of your branch to be on top of master. Which avoids any conflicts and helps to catch any failing tests before even merging your branch.
I quote rednaw:
You can revert commits with git revert . This will create a new commit which reverts the changes of the commit you specified with the .
Note that you only revert that specific commit, and not commits after that. If you want to revert a range of commits, you can do it like this:
git revert <oldest_commit_hash>..<latest_commit_hash>Just note that this command is a little bit funny. It actually doesn't revert the commit specified with itself, but the commits after that until and including .
Look at the git-revert man page for more information about the git revert command. Also look at this answer for more information about reverting commits.
Note that this revert command also deletes the corresponding local files
 
    
    Assuming that you mistakenly created a merge request on Gitlab, All you have to do is scroll to the bottom of the merge request page and click on the button close merge request
