How to buy a bike that fits or fit your current bike to you:
The two most important factors in a perfect fit are seat (or saddle) height and distance between the saddle and the handlebars. Frame size, stem length and stem height all affect these factors.
Frame Size: If you are buying a bike, the first thing to look at is the frame size. The frame should be big enough to allow you to raise the saddle high enough and small enough to comfortably stand over the bike with feet flat on the ground. Two inches is minimum crotch to frame distance. If you need to raise the saddle above the minimum insertion line stamped on the seat post, the frame is too small. The length of the frame is also important. If the frame is too small, you will not have enough room between your knees and handlebars or your position will be too upright. If the frame is too big, you will be stretching to reach the bars. This would make it impossible to get back for enough for steep downhills. Be sure to read on and understand all the factor before selecting a frame. Remember a good bike store, specializing in mountain bikes, can help you get a perfect fit.
Saddle Height: For a good starting point, sit on the bike with the cranks lined up with the seat tube. Place your heal on the bottom pedal. Your leg should almost straight. Your saddle is too high if your hips rock side-to-side while pedaling. It's too low if your knees have a lot of bend at the bottom of the stroke.
Saddle Position: Saddles can be moved forward and backward to position your body correctly over the pedals. Do not adjust the saddle to compensate for poor reach distance to the handlebars. To set the saddle position, sit on the bike (with help of a friend or one hand on a wall) such that the cranks and pedals are parallel to floor. Hang a weighted string from the bony protrusion at the top of your forward calf. This will allow you to see where your knee is with respect the pedal’s axis. Adjust the seat so the weight hangs about one and half inches behind the pedal's axle. If you prefer a high spin rate, you may want to move this measurement forward to as little as half an inch. If you are a masher and like to muscle up hills at low RPM, you may want to move this number back to as much as 2 inches.
Seam Length: Now that the saddle is in the right position, you need to get the reach to handlebars right. First, be sure there is enough room for your knees to come up without hitting the handlebars. You will need at least an inch of clearance. Second, be sure you can shift your weight back off and behind the seat for taming drop-offs and steep descents. To adjust the stem length, you must purchase one in the proper length. Your bike shop can help get one that fits you and your bike.
Seam Height: While riding, with arms slightly bent, your back should be at a 45 degree angle. Many bikes allow your stem to be raised and lowered (bikes with threaded fork). If yours does not (bikes with threadless fork), you will have to choose the stem's height at same time you choose the length (again the bike shop can help).
OK, that’s most of it. Now with your bike fitting pretty well, lets look at a few small details that can make a big difference:
Foot placement: Your foot should be place such that the ball of the foot is right on or just (1/4 inch at most) in front of the pedal’s axles. If you are using clipless pedals (cleats), also be sure you have equal amounts of movement in and out before they release.
Handlebar sweep: Most bars are bent near the end. Rotate the bars so the sweep is aimed straight up your forearm. This will keep your wrists in their neural position. Also position the grips shoulder width apart.
Brake lever angle: While sitting on the bike, with your fingers out in the natural position, they should just rest on top of the brake levers. This should position the levers inline with your fore arm. Be sure you can reach the brakes when you drop off the back of the saddle for those nasty drop-offs.
Bar-end angle: The bar-ends are used mostly while climbing. Set the angle so while you are standing and pulling on them, your wrists are in a neutral position. This will give the most power and least strain on your wrists. A good starting point is inline with the angle of your stem.
Now you should a have a comfortable and efficient mountain bike. Be sure to continue to make adjustment as you learn more about your personal riding style.
Many of these tips came from Ned Overend’s article in January 1997 Bicycling magazine.