I assume you would have to revert to the parent of the offending commit, cherry-pick the non-offending code, commit, then rebase the entire master branch on that new commit.
Then you'd have to repeat the process for all forks and branches. It'd be a huge pain, but I think it's doable.
I've never tried something like this, though, so there might be some complications.