Being overweight and out of shape and old, I am a terrible hill climber. But I have made a general rule for myself that I'm NOT going to push my bike up a hill, unless I've done something like blow up my knees and I'm in pain. It's kind of a point of personal honor for me. There's no dishonor in pushing the bike up the hill, but there's somehow MORE honor for me in riding it, no matter how long it takes.
I've come up with a little mind-trick technique that helps me when I get REALLY pooped on a climb. I stop to rest for a few seconds (I don't get off the bike, I just stop and put my feet down.). I drink some water, let my heart slow down and get my breath back. Usually 30 seconds to a minute is enough.
During my rest period, I pick an object ahead but close by... depending on how tired I am, it might be quite close (25 - 50 feet away or so). Maybe it's a particular bush on the side of the road, or a sign, or a milemarker, or a piece of trash, or simply a discoloration in the pavement. Doesn't matter what it is, it's just an object that represents an achievable short-term goal.
I say to myself "Self, you KNOW you can make it to that bush. You don't have to make it to the top of that hill (which I don't look at), just to that stinkin' BUSH. Look how close it is, you can do that!"
Then I put my feet back on the pedals and start going. When I get to the bush if I feel I can go farther, I pick another object and repeat it. If I really feel I can't reach that next object without resting, I rest again.
Sooner or later (later, usually ;-)), I find myself at the top without ever having climbed to the top. I just climbed from one target to another in goal-steps I *KNEW* I could reach, and THAT got me there.
Yes, I know it's dumb, just a silly trick mind-game I play on myself, but it works for me.
Needless to say, this technique works best when you have lots of time and are riding solo. ;-)