As to Gettysburg, an excellent read is “Retreat from Gettysburg”

Lee actually did an excellent job of moving his forces from that battlefield back to Virginia. There was a lot of Cavalry action including Custer attacking and harassing the supply trains and forces heading south. Despite the pressure, Lee was able to get the majority of the supplies his forces collected back to Virginia.