I just did this last weekend, swapped a white one out for a new red one.
All I did, after removing the cable/gear from the tranny, was give it a good yank and it popped right off. There is a small c-shaped spring clip that keeps it locked on there, if you look at the new gear, you will notice a hole in the side of it, if the old gear will not easily come off, you can probably look through the hole on the old gear for the little clip, once you find it, rotate the gear until you see the ends of the clip and stick a small punch in the hole to compress the clip together, then it should pull off. Though like I said, I didn't have to do this, it did not take much effort for it to come off.
Brendan