@mogima
Don't listen to this guy. Bears can run downhill and you're not going to do shit against a bear.
If it's a black bear, he's a scaredycat and you can scare him away by yelling and intimidating him.
If it's any other type of bear, start walking backwards as soon as you see it. Do not turn away from it and do not run. Hopefully he doesn't give a shit about you and you can leave. If he comes at you, you fall on the ground and play dead. He might bite you and hurt you, but that's better than dying. Hopefully he just felt like being an asshole and wasn't actually intending to eat you (man-eating bears are uncommon).
You do the 'play dead' thing because there isn't shit you can do against a bear. Not because it's some magical solution. Talking about anything else is like talking about a truck. You're not going to fight off a truck. You're not going to outrun one. Your best hope is that it loses interest in you.