I think you may be asking the wrong question. My guess is that some pressure of anxiety is building up within you and you have found that striking out relieves it. Instead of looking for alternatives to the behavior, it would probably be more helpful to look for the cause. If you deal effectively with what is creating the pressure, you won’t have the need to hit. If you can’t figure it out by yourself, I urge you to make an appointment for a few sessions with a mental health professional.
In the meantime, it is absolutely not, not, not okay to be hitting your girlfriend. Apologize. Tell her that under no circumstances should she put up with it. People who love each other don’t hurt them or threaten to hurt them. If you feel the urge, walk away! If you really can’t put an end to it, then please do her the favor of letting her go so she can find someone who treats her well.
I wish you well.