I think you just have to get used to predicting what gearing you can push up the hill. Once you get good at predicting the gearing you should be in, it comes as second nature.
(This is the answer that I got when asking a friend the same question. I'm new and he has over 10 years of racing behind him.)
Find a mentor to ask questions to and learn from. Most cyclists are pretty helpful to newbies.