GitHub started training AI on code hosted on their website.
Yeah, same as Google trains their algorithms with your email content, and many tools use Wikipedia text to train, etc.
If anything you produce is accessible from an external computer, assume it is being read and used in any way they want to, and there's nothing you can do to stop it. Act accordingly.
If you don't want other people to access your source code, keep the git repo in your own computer, or your own private network. Problem solved. Same for anything else.
The cloud is someone else's computer.