Hunter Pence homered and drove in three runs, while rookie Chris Shaw delivered the go-ahead two-run single to lift the Giants to a 5-4 win over the Padres Tuesday night.