I am going to over generalize but hey, it may help.
I have a vuddy who is new to riding. He is fit so he wanted to do a 50 mile ride for his first ride. He made it but really suffered. He simply wouldnt shift and blamed the bike the whole way (its a cross bike)
Finally after about 30 miles i got behind him and watched. He had about three gears out of the twenty he has he used.
So when we finally got back and he decided he actually wanted some advice, he is what i told him.
In general i want you to find a steady cadence that feels as though you could hold that cadence and effort level for an hour. Focus on maintaining that effort level and cadence, and shift to match your grade. On even slight inclines shift to an easier gear. Get ahead of the grade, as in. Ot waiting until the grade forces you to shift down or mash harder, but anticipate the grade and get in the easier gear earlier so you dont have to slow your cadence. Remeber the opposite as you crest the incline...get back in that harder gear so you can build speed and still maintain that effort and cadence.
Chain rings....in general you will be able to reognize a grade you can still maintain in the large vs small ring with a little vit of riding experience. I try and not use the two largest rear cogs while in the large front and vise versa, i try not tomuse the smallest two rear cogs, while in the small front. Within the range thats left, find on your own when your going to need to shift down to the small chainring, and again try and anticipate that before you get hard into the climb.
In short dont mash and see if you can hold x speed or go up x grade...shift first and tey and make it easy...you can always shift back if you spin out....you paid for 20 gears use them.