PITTSBURGH — San Francisco turned some of those fly-ball outs into home runs.

Gorkys Hernandez homered off Ivan Nova to spark a five-run sixth inning, Nick Hundley added a three-run drive and the Giants beat the Pittsburgh Pirates 5-0 Sunday to stop a season-high six game-losing streak.

“We hit probably nine, 10 balls right on the screws that their outfielders made plays on,” Hundley said. “So, it was nice to get a couple over the wall then open up the game a little bit.”

San Francisco averaged 8.25 runs per game while winning four in a row from May 2-6 but averaged just two runs per game in the first five games of its losing streak. With back-to-back five-run bursts, manager Bruce Bochy hopes the offense may have reignited,

“I think we had some really good at bats and finally broke through,” Bochy said. “Last couple days, they’ve been a lot better.”

Derek Holland (2-4) allowed four hits and five walks in 61/3 innings with seven strikeouts, repeatedly pitching out of trouble. Pittsburgh went 1 for 11 with runners in scoring position, including 0 for 8 against Holland, who allowed runners to reach second in four innings.

“I’m still a little upset with this one even though I got to go 6⅓,” he said. “The five walks, that’s the killer. I did a good job, though, of keeping them from scoring.”

Reyes Moronto, Will Smith and Hunter Strickland completed a seven-hitter, the fourth shutout for the Giants this season.

Andrew McCutchen was 1 for 4 with a walk and went 4 for 14 (.286) with three doubles in his first series at Pittsburgh since the Pirates traded the five-time All-Star to the Giants during the offseason. He extended his hitting streak to 12 games, and he is 16 for 43 (.372) in that stretch.

Nova (2-3) gave up four runs and eight hits in 5⅔ innings and is 0-2 in five starts since beating Miami on April 15.

Brandon Belt and Pablo Sandoval singled following Hernandez’s homer, and Hundley homered on the first pitch from Richard Rodriguez.

Now the Giants hope for a boost for their pitching stuff. Left-hander Madison Bumgarner, out since the end of spring training with a broken left hand, is expected to throw off a mound today. If his rehab goes well, he could be ready when he is eligible to be reinstated from the 60-day disabled list on May 25.