I have invented a new algorithm that I want to patent in Germany/Europe. However, I have kept my code implementing the algorithm in a public GitHub repository. I have not assigned a copyright license to it. The question is, can I patent this algorithm now? or does keeping it in a public repository invalidate any patent applications?
If you are applying in Europe via the EPO you have to contend with their definition of “made available to the public.” In section G IV we find
6.4 Internet disclosures As a matter of principle, disclosures on the internet form part of the prior art. Information disclosed on the internet or in online databases is considered to be publicly available as of the date the information was publicly posted.
In general code itself is protected by copyright not patents. However, you may potentially get a patent on an algorithm as applied to specific task or problem. The mathematical algorithm by itself will almost assuredly be considered abstract and thus unpatentable. My understanding is that algorithm based patents are hard to obtain in Europe, but I'm not an expert.
By publishing your code, you make it prior art and thus your algorithm is unpatentable. In the US there is a 12 month grace period so depending on when you uploaded it to Github you might still be able to pursue a patent there. It's possible if you delete the Github repository it might not be discovered by the patent office, but you are probably out of luck.
I am not a lawyer and this is not legal advice. It would be best to consult with an actual patent attorney.