The best way to disconnect a soldered pipe is to cut it. But sometimes you can’t—either because you can’t get a cutting tool into the space or because cutting would leave the pipe too short to make a new connection. The solution is to heat the joint and pull off the fitting as the solder melts.
Have a wet rag handy and immediately wipe away the molten solder before it hardens. (Wear gloves to prevent burning your fingers!) Sometimes a quick wipe will leave the pipe ready for a new fitting. More likely, you’ll have to scour off some excess solder with sandpaper or emery cloth before you can slip on a new fitting.