This is a long one, so bear with me! While mountain biking this past weekend, I broke a spoke. This can happen as a rim slowly gets out of true and puts more tension on a part of the wheel than another, or by an awkward impact. They can break near the hub or the rim, but usually don't break in the middle. When this happens mid-ride, it's best either remove it (if you can) or twist it around a neighboring spoke to keep it from becoming entangled in the drive train.
Here's how to replace a spoke on a back wheel on the drive side of a geared bike.
Step 1: Since the spoke is on the drive side, the cassette will have to come off in order to get at the spoke. On the front wheel, you wouldn't have to remove the cassette (...). There are many kinds of cassette removal tool for the different kinds of cassette. The one we need looks like this:
Cassette removal tool for a Shimano Cassette
Since the freewheel naturally spins to the left, when you take it apart you have to keep the cassette from also spinning. This is easiest done with a chain whip (the blue tool on the right). If you try to use your hand or a rag you will end up using the rag to stop the bleeding on your hand.
Chain whip and cassette tool on the wheel
Step 2: Once the lockring is loose, you can un-thread it with your fingers. After it's out, the cassette will slide right off the free hub body. You can see that the outside free hub body is splined, and the pattern matches the inside of the cassette. This pattern only allows you to put the cassette on one way, so the shifting works smoothly.
Pulling the cassette off
Step 3: With the cassette removed, we can easily slide the spoke out and the new spoke in. A word on spoke length: it's important that the old spoke and new spoke have the same length. Too short and the threads on the spoke won't reach; too long and it can go all the way through the spoke and puncture your tube.
Removing the spoke
Step 4: Take the tire and tube off and peel back the rim tape and you can see the top of the spoke.
Pulling the rim tape back
In this case, the end of the spoke had broken off in the end of the nipple (top) and needed replacing along with the spoke.
Nipples, old vs. new
Drop the new nipple in the rim and thread it onto the new spoke. The top of the nipple is slotted to fit a flat head screwdriver, which makes getting the threads started much easier. Don't forget to replace the rim tape.
Step 5: Use a spoke tool to tension the spoke and true the wheel. The wheel will probably be a little out of true after losing a spoke. Use a spoke tool to tighten and loosen the spokes until the rim is true and properly tensioned.
Using a spoke tool
Step 6: Reassembly is the reverse of disassembly. When tightening the cassette a chain whip is not necessary as the freewheel is working with you by against you. Note: be sure you have the directional tires going the correct direction!
Sometimes, after truing a wheel and riding, it will settle and some minor adjustments will need to be made. Piece of cake! Now, reward yourself with a beer!