How to revert few commits on a Git repository

I'm using Bitbucket and I made a few mistakes on my local repo and pushed to the server by mistake, how can I do to revert that commits?

Just don't do it!

Is a back practice change your commits on that way, could be other coworkers who already pull that commit and if you delete it thats gonna be a big problem.

How ever if you have to or are developing alone you could do something like that to revert your commits:

git reset --hard HASH

That command is to point the HEAD of our repo to the specific commit (identify by the HASH parameter) and the next command you should run is:

git push -f

That command is to force the changes into the repo on the server and it's done we revert the state of our online repo to the specific commit.

source