If you are hitting her cervix rather than stretching her vagina then it isn't really a question of length it is a question of arousal (hers) and of angle.
The cervix is not at the end of the vagina - it is not the toe of the sock, so to speak. Using the sock metaphor, picture a long sock with a short foot, please - the cervix is more like the heel. You quite easily slide a long object into the sock without it bumping the heel.
When a woman is fully aroused her vagina 'tents' - that is muscular tension pulls the uterus upward, making the vagina deeper and wider. It also tucks the cervix further out of the way. So the more turned on your girlfriend is before you penetrate her the less likely she is to feel pain. Lots of foreplay!
Also, does she complain of pain in all positions or just some? Do you have sex in lots of different positions or do you tend to do the same thing most of the time? If there is just one position that hurts her, avoid it - or only shallow penetrate her in that position. If you don't vary things that much then it is time to start.
Another factor related to position is curve. Is your cock completely straight or does it curve up, down, a little, a lot? Men with curved cocks have to be aware of how that affects a partner. And of course not all women like the same stimulation - you might find one woman adores doggy with an upward curve and another finds it uncomfortable.
Of course it could well be that she just isn't built to accommodate your size, in which case you have to be aware of that and adapt to it. There are several ways to prevent full penetration - place one hand (yours or hers) at the base of your cock while you fuck, or have her go on top and control the depth of penetration, or move your hips up her body slightly - this one has the added benefit of your cock rubbing her clit as you fuck.
I think a very first step, though, is to let her know that you really don't want to hurt her and that you're willing to work on it with her and that you will always stop if she tells you to. That's important - she needs to be able to relax and trust you.
Good luck. Have fun making it work.