PHOENIX (AP) Joe Panik said he had never swung on a 3-0 pitch since he got to the major leagues.
When he did Friday night, it turned out to be the swing that won the game.
Panik sent Shelby Miller's pitch over the right field fence for a three-run homer that provided all the offense Jeff Samardzija and the San Francisco Giants needed in a 3-1 victory over the Arizona Diamondbacks.
When manager Bruce Bochy gave him the green light to swing, Panik was ready.
''In a situation like that I'm excited because you've got a runner on third, nobody out, you're looking for a fastball,'' he said. ''I'm just looking for a pitch I can drive.''
It was Panik's second home run in two nights.
Samardzija (5-2) pitched out of trouble early and went eight innings for the third time this season, giving up a run and scattering eight hits to improve to 4-1 in his last five starts. After throwing 123 pitches his last time out, he threw 112 on Friday.
''We worked him hard last game,'' Bochy said. ''Here he goes out and gets us eight innings and his stuff was just as good.''
Samardzija's performance followed Johnny Cueto's strong effort in the Giants' 4-2 victory in the series opener Thursday night.
San Francisco's top three pitchers, Madison Bumgarner, Cueto and Samardzija, are a combined 14-5.
''You've got to keep pace, right?'' Samardzija said. ''It's awesome when you've got guys in front of you that are doing that and showing you the way, and you don't want to let everyone down.''
Miller (1-4) blanked the Giants on four hits through five innings but faltered in the sixth, allowing two singles before Panik's home run.
''At that point of the game I felt like, after getting that run in the bottom of the fifth, I felt that the momentum was on our side,'' Miller said. ''I was just frustrated about giving up three more runs in one inning. It gave them momentum with that home run and I was pretty upset about that. `'
Miller's first career triple, and Jean Segura's RBI single, had given Arizona a 1-0 lead in the fifth.
''It really fired me up, man,'' Samardzija said. ''I was not too happy with that. In a 0-0 game the last thing you want to do is break that tie giving it to the pitcher. I just wanted to make sure the rest of the game I redeemed myself.''
Miller went 5 2/3 innings, giving up three runs on seven hits.
Left-hander Josh Osich retired left-handed hitting Jake Lamb for the first out in the ninth and Santiago Casilla came on to strike out the final two for his eighth save in 11 tries.
The visitor won for the 22nd time in the last 27 meetings between the teams. Arizona fell to 5-14 at home.
The Diamondbacks turned five double plays, in the second, third, fourth, eighth and ninth innings, to tie a franchise record.
Arizona stranded four runners, three in scoring position, in the first two innings.
Casilla said before the game he had apologized to Bochy for his emotional outburst on the mound Thursday. Casilla was upset when Bochy pulled him with two outs and the bases loaded in the ninth inning. Bochy brought in lefty Javier Lopez to face left-handed hitting Lamb and got the Arizona batter to ground out to preserve the victory.
Casilla said after the game that he thought Bochy had shown a lack of confidence but said after thinking about it overnight that he was wrong.
''What was said is between us,'' Bochy said. ''It's over.''
Giants: Angel Pagan was back in the lineup after missing 11 games with a hamstring strain. He singled and scored a run. ... RH reliever George Kontos was to make a final rehab appearance for Triple-A Sacramento Friday night. Bochy said Kontos could rejoin the Giants in San Diego on Tuesday.
Diamondbacks: OF David Peralta missed his fifth straight game with right wrist soreness. An MRI on Thursday did not reveal any structural damage.
Giants: RH Jake Peavy (1-4, 8.47 ERA) takes the mound in the third game of the series Saturday night after losing his last three starts, most recently a 3-1 defeat against Toronto on Monday.
Diamondbacks: LH Patrick Corbin ( 1-3, 4.12) goes for Arizona after pitching seven scoreless innings in his last outing, the Diamondbacks' 11-inning, 5-3 win at Atlanta on Sunday.