The Padres stayed on top of the National League wild card race by one game over Philadelphia and moved within a game of Arizona in the Western Division.
But the pennant race was secondary for the home fans, who turned out to watch Bonds play his final game in San Francisco. He had not played in 11 days because of a sprained toe and he limped through Wednesday night's contest.
Bonds was hitless in three at bats and left the game after driving a ball to the warning track in center field. He stepped out of the dugout to acknowledge the cheers of the crowd after what might have been the final at-bat of is career.
The Giants have announced they will not re-sign Bonds, baseball's all-time home run leader.
Greene and Bard both had two-run singles in the fifth and Jake Peavy (19-6) got the win, giving up five hits and two runs over seven innings.
Pat Misch (0-4) was shelled for nine hits and eight runs in 4 1/3.