SAN FRANCISCO -- Joe Musgrove made some adjustments to his delivery, and he's enjoying the results.
The Pirates took three of four in the series, and have won 14 of their last 20 games in San Francisco dating to 2014.
Evan Longoria homered for the Giants, who've lost four of five.
Musgrove (10-12), who missed his last start with right foot discomfort, has been working with assistant pitching coach Justin Meccage on shortening his delivery.
"I'm trying to eliminate a couple of steps in the backswing here and just make it a little bit shorter motion," Musgrove said.
"I used to be a lot shorter in the back and over the years I've gotten longer, but that comes with the rigors of a long season. Sometimes your arm's not feeling great and you've got to make up for it and you've got to find the adjustment to make it feel better."
Musgrove struck out seven, gave up four hits and walked none. The right-hander threw 18 of 19 first pitches for strikes.
"That's sick. That put him in play for everything else," Pirates manager Clint Hurdle said. "The curveball and slider played off each other. His fastball command was good with the two-seamer and four-seamer, only one three-ball count."
Pirates closer Felipe Vazquez worked around a first-and-third, no-outs situation in the ninth for his 28th save in 31 attempts.
Vazquez, who on Monday was involved in a clubhouse brawl in which he punched teammate Kyle Crick, notched his third save in four days.
Musgrove tripled leading off the fifth and scored on Adam Frazier's single to make it 3-0.
Longoria hit a two-run homer off reliever Yacksel Rios -- his 19th -- in the Giants sixth.
Stallings hit his sixth homer and second of the series leading off the seventh against starter Jeff Samardzija (10-12).
San Francisco has dropped nine of its last 11 home games and is 31-41 at Oracle Park this season.
"We've had some pretty good days on the road but here at home for some reason we just have a hard time getting it going. And then today, he (Musgrove) did throw well, but we just couldn't get much going." -- Giants manager Bruce Bochy on the team's struggles at home.
Musgrove's triple was the first by a Pirates pitcher since May 29, 2010, when Brian Burres did it.
Pirates: CF Starling Marte was out of the lineup for a fourth straight game with a left wrist sprain he suffered making sliding catch on Sunday against St. Louis.
Giants: Manager Bruce Bochy moved up RHP Johnny Cueto's next scheduled start two days to Sunday, the finale of a three-game series against Miami. The two-time All-Star, who pitched five shutout innings in his first game back from Tommy John surgery on Tuesday, had been scheduled to make his next start on Sept. 17 in Boston. . LHP Will Smith (back inflammation) will play catch on Friday. Bochy said his All-Star closer could be back on the mound as soon as this weekend. . OF Alex Dickerson (right oblique injury) took 40 swings on Wednesday and planned to do the same on Thursday. He'll hit against a machine on Friday and could pinch hit over the weekend, Bochy said. . OF Jaylin Davis left the game for a pinch runner after being struck by a pitch in from Rios in the sixth. X-rays taken after the game were negative. He suffered a contusion, Bochy said.
Giants: RHP Tyler Beede (4-9, 5-33) will pitch Friday's series open against Miami. Beede ended a streak of nine winless starts in his most recent outing on Sept. 7, when he pitched five innings of four-hit ball in a 1-0 victory over the Dodgers.
More AP MLB: https://apnews.com/tag/MLB and https://twitter.com/AP-Sports
Ex-Reds infielder Jose Peraza agrees to join Red Sox
The Red Sox have agreed to a one-year deal with free-agent infielder Jose Peraza, according to a report Thursday by Robert Murray.
Winter meeting notes: Nomar Mazara, Tanner Roark get fresh starts
The White Sox hope to tap Nomar Mazara's potential, while the Jays and Mets found rotation help at a fair cost.
Corey Knebel, Brewers agree to same $5.1M salary
The Brewers agreed to a one-year contract for $5,125,000 with pitcher Corey Knebel, who is returning from Tommy John surgery.
Bruce Bochy to manage France for WBC qualifiers
Former San Francisco Giants manager Bruce Bochy will manage France in its qualifiers next year for the World Baseball Classic.
Source: Catcher Austin Romine reaches one-year deal with Tigers
Free-agent catcher Austin Romine, who had played only for the Yankees during his eight seasons in the majors, has agreed to a one-year deal with the Tigers, a source told ESPN.
Tigers take RHP Rony Garcia from Yankees with top pick in Rule 5 draft
Right-hander Rony Garcia, a Yankees prospect last season, was chosen by the Tigers with the top pick in the Rule 5 draft.