The correct way to do exactly what you describe is to use the git revert command.
You would find the offending commit(s), checkout the tip of your branch and execute this command if it is only one commit you want to revert:
git revert SHA-OF-COMMIT
If there is more than one commit, in sequence, that you want to revert you would do this:
git revert SHA-OF-OLDEST-COMMIT..SHA-OF-NEWEST-COMMIT
If you want to revert multiple commits that aren't sequential (there are other commits inbetween), do the revert operation in multiple steps.
In either case new commit(s) will be created that reverse the changes introduced by the commit(s) you wanted to revert. You do not lose the original commits, they're still part of history, but the changes they introduced has been removed further down the history.
This is the safest route if your repository is a shared one as it only creates new commits. git revert
is not the command to use if you need to completely eradicate all traces of the commit, including historically, then you would need to do history rewriting but this does not seem to fit with your question.
Tip: Make a complete copy of your entire working folder and git repository locally before you start to ensure you don't do anything that requires extensive cleanup.