For each commit (in reverse chronological order) that has mistakes, do:
git revert <sha of commit> --no-commit
git reset head
This will make your working copy reflect the repository, minus all the changes introduced in the specified commit. You just want to revert some of the changes; to do this, you will want to add just those reversions to the index. You can do this with the command line, but that can be quite cumbersome. I would recommend using a tool like Source Tree instead; with that, you can just visually select which hunks in which files you want to stage.
Once you are satisfied that the index contains all the reversions you want, go ahead and git commit
them, then do a git checkout .
to clean up your working copy. Then move on to the next commit you want to (partially) revert.
Note that if your mistakes are spread over a bunch of commits and you do not want to revert each commit individually, you can pass a range of commits to git revert
as well.