1) Flip your bike upside down and remove the wheel by releasing the lever—called the "quick release"—on the outside of the wheel. If you have a 2012 mountain bike or newer and a flat on your rear wheel, you may have a clutch, a small lever on your derailleur. Open it. On any bike, unscrew the release to remove the axle, while holding the nut on the opposite side of the wheel at the same time. Replace the axle so you don’t lose it, and turn your attention to the tire.
2) Release any remaining air out of your tire by depressing—or unscrewing and depressing—the valve. Hold the wheel on its rim while you do this, applying pressure from the top to squeeze out extra air.
3) With the brake rotor towards you, so you won’t slice your finger if you slip, grab the rubber tire and roll it back and forth to break the bead-rim seal. Pinch the bead towards the center of the rim. As you work your way up both sides of the rim consecutively, this should give you slack in the tire rubber, enough to pop the bead over the edge of the rim and pull one side of the tire off. Alternately, work a tire iron or two under the bead, then pop the bead off the rim.
4) If there is a nut that secures the tube valve to the rim—remove it. Then, remove the tube. Re-inflate the damaged tube with a bike pump and look for the hole. Slide your hand along the inside of the tire feeling for the cause of the puncture(s) and remove offending objects. The tube will give you clues where to look.
5) Replace the tube. Install the valve stem and nut. Do not twist the tube as you lay it inside the tire. Add a pump or puff of air to the tube to make this step easier.
6) Beginning at the valve, tuck the tire bead back under the edge of the rim. Work your way up both sides of the wheel at the same time. At the top of the rim, opposite from the valve, the tire will be hardest to get over the rim. Brace the valve side of the wheel on the ground or against your body. Grasp the last bit of tire and with two hands, and with your thumbs, roll it away from you until it pops over the rim.
7) Once the tire is on the rim, inflate the tube half way—recommended pressure is noted on the side of the tire. Gently roll the tire back and forth on the rim, looking for spots where the tube may be protruding. If you need to, release air and pull the tire over the tube. Fully inflate the tube.
8) Replace the wheel, lining up the rotor up with the brake, and replacing the axle with the lever side away from the brake. On the rear wheel, re-engage the clutch.
9) Spin the wheel. If there is any drag, release the quick release and re-lock it, re-centering the wheel.
10) Don your helmet, and hit the road or trail!