This is essentially almost the same if you want to delete the current commit . You probably want to go back to the previous commit , so you need to get the current
git reset --hard HEAD~1
If you want to go back to some other specific commit it should use hash . Or in some cases you can do
git reset --hard HEAD^
Try with --soft
before and see if it solves what you need. It is less radical and more secure.
If commit has already been sent you will have to force on the remote:
git push origin HEAD --force
This will cause all local changes to be lost. So if you can not lose them, I suggest doing a stash with all of them before.
If it goes wrong it can revert like this:
git reset HEAD@{1}
If you're scared to do something wrong, make a backup before and you can go back to the original if you did not quit as you expected.
If you want to do on the remote:
git push origin +HEAD^:master #ou outro nome aqui
If fear extends to the remote server, do the same with it. If you involve the remote server, various care needs to be taken, the main thing is that your current branch should be the newest of the remote. If this is not guaranteed, you will be creating an alternate reality for other users.
Read recommended .