sex after baby

had sex 5 weeks after delivery. hurt and hubby couldn't get much past the head but he didn't pull out 😠 he cum barely in so when he pulled out it come out immediately. I don't want pregnant again for a while so we done with sex til I'm over this happening but anyone ever had this happen and not get pregnant. I'm strictly breastfeeding every 2 hours and have since baby come.