Most of the time, the best way over an obstacle is head on.
Throttle control is critical, so practice. Too much and, instead of lifting the front wheel, you'll flip the bike. Start with little rocks or logs and work your way up.
Don't lay off the throttle after you get the front wheel up or over. Keep the momentum going to bring the back wheel along as well.
Some obstacles are just the right height and width for you to get hung up on the frame, putting you on the center of a dirt bike teeter totter. Be ready for it -- your first instinct will probably be to lean forward, or your momentum may cause you to lean forward. You want to lean backwards to keep the rear wheel on the ground and keep the bike moving.
Always ride straight up or straight down a hill. Climbing a hill at an angle, or traversing (moving parallel to the slope) it is a good way to lose control, fall off, or start rolling downhill.
If you're riding a trail up a steep hill and end up stopping for any reason, hit the brakes and stay on them until you're ready to go again. Don't try and turn around to go down, or you'll probably end up going down the hard way. Depending where you are on the hill, you may be able to slowly ease yourself down backwards, or dismount and push the bike up (hopefully with some help from a buddy).
In mud or loose sand, you may be tempted to crack the throttle -- the faster the wheel spins the faster I'll go, right? Wrong. Spin too much and you lose traction. If you get stuck, you can try a little throttle -- but if you start spinning the tire, stop... otherwise you'll just dig the tire deeper.
Crossing water is basically dangerous. If the water is murky or deep you can't see what you're riding over. Even shallow, narrow streams can have rocks covered with slippery algae, loose gravel, or tire gripping muck. Take it carefully.
Other riders can be an obstacle too. Don't follow too closely. Always assume they're about to crash and figure out if you have enough room to stop. Also, remember, another rider may be coming down the same trail in the opposite direction.