Hi @Mouad1307
For my answer, I am assuming your girlfriend has German citizenship.
The situation is different before and after the birth of the child.
Before the birth:
Fathers do have the right to go to Germany already before the birth to be there during the pregnancy and for the birth of their child. This right is not stated clearly in the immigration law but is generally accepted to be possible. For this, it is not sufficient to have the recognition of paternity. You also have to show you have shared custody (Sorgerecht).
Here you can read an article about such situations:
https://tarneden-de.translate.goog/aufenthaltserlaubnis-bei-schwangerschaft-fuer-werdende-mutter-oder-vater/?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp
If you have shared custody, then you can apply for such a visa in your home country or any other where you have habitual residency. Here is an example of the application process for expectant fathers from the German embassy in Chile. The procedure should be the same in all embassies but not all have such detailed information about it online:
https://lima-diplo-de.translate.goog/pe-de/konsularservice/visa/-/2103686?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp
If you travel without a visa, you can apply directly in Germany for a permit on this basis as ‘expectant father of a German child’. However, the authorities only allow this in exceptional cases where it is not reasonable to expect the person to leave Germany in order to go through the visa process. It is possible you may instead be issued with a temporary residence paper to allow you to stay until the birth. It is, however, also possible that you would be ordered to leave the country within a specific deadline. The authorities have some discretion in whether to allow you to stay or not.
After the birth:
You will be father to a German child. As I understand, you have the recognition of paternity but not custody rights. This means you still have access rights as a parent (Umgangsrecht). You have the right to have regular contact with your child. Without shared custody, you are not entitled to a residence permit as the parent of a German child. At most, you can get the temporary status of ‘Duldung’ as long as you have contact with the child. At a later period, you can change to a regular residence permit but this would depends on other requirements being fulfilled. You may at that point also be required to leave Germany to go through the visa process first.
If you do have shared custody, you are entitled to a regular residence permit. You will, however, be asked to first get the required visa. In cases of young children, it is not reasonable to require a parent to leave and go through a lengthy visa process and so the local immigration authority (Ausländerbehörde) should process your application directly. But it is a matter which potentially may need you to go to court. Here is an article which discusses this issue:
https://***-advogarant-de.translate.goog/rechtsanwalt/gebiete/rechtsanwalt-fuer-internationales-recht/nachholung-visumsverfahren?_x_tr_sl=de&_x_tr_tl=en&_x_tr_hl=en&_x_tr_pto=wapp
In conclusion, it is a complicated situation. You do, however, have rights both as an expectant father before the birth and as a father after the birth. I recommend you get assistance in best being able to assert these rights.
Please note the links are in English via online translation.
Best,
Éanna