The key to pitting these fruits is a light hand -- you'll want to keep the soft fruit bruise-free and intact, while getting that stubborn pit out. Here's how:
Wash the fruit under cool running water and pat dry with paper towels.
Using a sharp paring knife, slice into the stem end of the fruit until you reach the pit. Rotate the peach around the paring knife so that you're cutting the fruit all the way around the pit into two halves.
Set down your knife. Grasp one half of the fruit in each hand and gently twist the halves in opposite directions. The halves will separate, and the pit will remain in one of the halves. (Note that the pits of some nectarines may be particularly clingy, making it difficult to pry the fruit into two pieces. If this is the case, cut the nectarines into smaller sections, cutting them away from the pit as you go.)
Use your paring knife to loosen the top and bottom of the pit from the fruit. At this point you can usually use your thumb and forefingers to remove the pit from peaches. For nectarines, use the tip of the knife to pry the pit from the fruit.