I accidently make my repo public but I forget to make my repo private at that time someone fork my code. But I make my repo private instantly but I didn’t want my source code to be present in others repo. What should I do now?
I’m afraid there isn’t much you can do, because anything you’ll do won’t be backward effective.
The GitHub EULA and terms grant to every user the right to fork public repositories, and this is an irrevocable right to which you also agreed by accepting the service terms. If there are legal grounds for remedying this situation, then you should contact GH support via email.
Being able to fork a repository doesn’t affect its copyright status in any way. So, unless your repository has a license that allows creating derivative works, its forkers are not allowed to make changes to its code (which could be derivative work, depending on the nature of the changes), nor reuse your code without asking you permission to do so.
Probably this is not going to alleviate your pain, especially if you intended your code to remain proprietary and protected from preying eyes — the former still holds true, but for the latter it’s too late.
Now that you’ve made your repository private, you can at least protect all your future code changes from the public, which is better than nothing.
IMPORTANT DISCLAIMER! — none of the above constitutes legal advise! I’m not a legal expert, nor a GitHub representative, and everything I write is my personal opinion and understanding, nothing more, nothing less.