Please help

My husband and I are going to get a divorce, he has legal custody of my daughter he convinced me to give it to him just in case something happened to me and my mom or nobody could take her, now I want joint custody but he won’t give it to me he said he wants primary and I can get visitation.. but he is so abusive to me physically and mentally and I don’t make a lot of money because I just started working I been a stay at home, is there anything I can do to get my daughter and leave please tell me I have to protect me and my baby and I don’t want to go to jail for kidnapping