If the code is GPL licensed, you can't relicense it under a non-FOSS license like you're talking about
> Don't they then have to remove that code?
Yes, if code gets uploaded whose license is incompatible with Microsoft's terms, they probably do have to remove it.
> Now imagine this: I write some code, license it, but don't publish it yet. It's licensed. Then I upload it to github. Does the license supersede the ToS? Doesn't github have to remove the code as a ToS violation
Again, yes, they probably do, and they also probably have an obligation to clean their training data of it. However, if you're the copyright holder of the code and you agree to their ToS before uploading, they might make the case that you agreeing to their ToS does grant them the license to use it in training data.
So then Github is breaking the law a significant portion of the time then at the very least?
Facebook wouldn't be able to allow users to upload photos.
Hacker news wouldn't allow me to post this comment (someone else could own the copyright, right?)
You are violating the law, probably. The ToS would say something like "I hereby declare that I hve the right to agree over the software to submit it under the ToS".
However, the reality is that this is all extremely muddy, far from proving that software A has copied some code from software B where you can just compare the source code. There are too many muddy steps, and you can bet that Microsoft will just get away with it.