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 as parents are not married to each other at the birth of your child, you can obtain joint custody by making both custody declarations.