As a family member of a German, you can, under certain conditions, apply for a permanent right of residence (settlement permit) after a three-year stay in Germany.
You should apply for an extension of your residence permit in good time before the validity of your child born in Germany expires.
If you are not married to each other as parents when your child is born, you can obtain joint custody by making both declarations of custody.