Revert is usually a safe operation as it create a new commit.
git revert <SHA>
Before you revert a commit, you might want to check what was change in the commit as you might want to keep changes that were lumped in the commit:
git show SHA
If you made a commit in the wrong branch:
Go to proper branch and run:
git cherry-pick <HASH>
go to old branch, run:
git revert <HASH>
In case of error see: https://blog.seobytes.eu/development/git-returns-is-a-merge-but-no-m-option-was-given/