I've had about half a dozen encounters with black bears around the Lake Shasta area. Most of those were bears trying to enter my campsite but one was a bear boarding my houseboat.
The rule I've always used is that you can do just about anything to discourage the bear until it gets your food. Then you leave it alone.
So I've stood about 20' from a black bear, throwing rocks and pine cones at it while waving my stick and yelling... felt like one of the more dangerous things I've done but the bear left each time. Happened at night one time, we scared it away and it went over to a nearby campsite where the family tried to be quiet and ignore it. We heard screaming when it started pawing around the tent and ran over to help. Those folks packed up and boated out that night.
This is just my experience with California black bears. I have heard that it doesn't apply to brown bears but haven't had the pleasure of encountering one yet.