So, the question that bothers me is could the same happen to Bitcoin?
I don't think so. Bitcoin is not illegal and its current direction is getting adopted by large institutions. They can easily lobby against this kind of measures if it's the case.
What will happen to Bitcoin if the US Government suddenly decides to take down its Github repos?
Take down is not likely, maybe restricted access, but that means that reading is still possible.
If it's indeed taken down then internet archive still exists, many people also have local backups... it may be a small setback, but far from "the end of the world".
What if they ban all contributors, maintainers, and lead developers? Is there a place where the bitcoin codebase can migrate to? Are there other code hosting platforms besides Github that are not based in the US or upon which US Government sanctions have little to no influence?
In theory anyone can host a system similar to Github on his computer, just if it's not publicly visible there may come trust issues.
And obviously all the bigger systems like this are centralized. The most known is GitLab, but a list would be here:
https://stackoverflow.com/a/24256558Is it possible to build a decentralized and distributed code hosting platform that no one can censor or shut off?
Probably. But first the decentralized file system platforms need to become more robust/reliable, not just new wannabe projects. Also I expect that using such services cannot be for free.