Anticipating the shift - and shifting before you have to - helps.
But you also need to have a good, smooth pedal style on hills.
Are you riding clipless pedals??
On a slight incline, not really much of a hill, where you have a broad shoulder or light traffic, unclip one foot, and pedal with one foot. You will really feel how choppy your pedalling may be. Work to make sure you pedal in circles, not up and down.
Switch feet, and pedal one-footed with your other foot (you will find one leg is MUCH stronger than the other).
One-legged pedalling drills will really help you smooth out your pedalling. You've got to pedal circles up hills. Put your hamstrings to work, not just your quads. It helps make going up hills much easier.
Oh, and stay up on the flats of your handlebars - never the drops - with a light grip. I was amazed at how many women climb in the drops (I used to) when I did a recent race. It helps you breathe to be up high.