Matt Chapman homered in a third consecutive game as the Giants rallied from a four-run deficit to beat the Pirates in the series finale on Thursday.