R.E. Lee should have listened to Longstreet and slipped to the right flank (south) and found himself better ground to fight a defensive battle.
He certainly should have left Gettysburg after July 1st. If he did indeed find some good defensive ground there is still no guarantee that Meade would have attacked him.