This might be a duplicate, I just didn't happen to find one.
Basically the scenario is: there were some minor changes to a file in some commit, and now the file has been modified even more (to add new features, etc.).
What I would like to do is to automatically undo (if possible) the changes to the file in that commit, without actually going back to an old revision of the file; i.e., whatever the diff for that commit was, the reverse of it should be applied to the current version. The result is a new "fixed" version of the latest file.
I realize it isn't always possible for a computer to do this, but when the future changes after the bad commit are completely unrelated and in a different location, it should be possible. How can I do this?