Mired in last place in the National League West since mid-May, the Giants used an 8-4 win on Saturday night to put themselves in position to complete a second straight series win and cap what would be their best week of the season with six wins in seven games.
Despite the loss, the Cardinals can still salvage a winning trip that has seen them take four of eight, including 9-4 in the series opener on Friday night.
The Giants survived a scare when ace left-hander Madison Bumgarner had to leave Saturday's win at the start of the third inning after having been hit by a line drive near the left elbow by the second batter of the game. X-rays were negative.
While losing Bumgarner obviously was a concern, Giants manager Bruce Bochy had to be pleased with the final result, especially after lamenting about the club's lack of offense at home after Friday's loss.
"We haven't scored as much here," he told reporters. "The offense hasn't quite clicked here like it has on the road. The offense just hasn't quite been good enough here at home."
Samardzija has won two of his last three starts, and is coming off one of his best efforts of the season on Monday, limiting the San Diego Padres to two runs and five hits in eight innings.
The veteran will have to deal with Cardinals slugger Paul Goldschmidt, the all-time leader in home runs by a Giants opponent at Oracle Park. Goldschmidt hit his 13th at the stadium in Saturday's loss.
Samardzija has dominated the head-to-head over the years, limiting Goldschmidt to a .229 batting average (8-for-35), with just one home run and 15 strikeouts in 41 plate appearances.
A former pitcher in the NL Central with the Chicago Cubs, Samardzija hasn't had anywhere close to that kind of success against longtime Cardinals star catcher Yadier Molina, who has hit .429 (12-for-28) in the head-to-head.
But it appears the Giants will catch another break Sunday when Molina, who is recovering from a sore right thumb, likely will get a fourth consecutive day off leading into even more recovery time during the All-Star break.
"It's going to help," Cardinals manager Mike Shildt said of the midseason downtime. "We're pretty intentional about getting (the thumb injury) behind him. It's a tolerance issue right now, but we just want to be smart about it. It just makes sense with the schedule to continue to give him some rest."
Overall, Samardzija is 4-5 with a 3.77 ERA against the Cardinals in 24 appearances, including 13 starts.
Having scored 52 runs in their last six games, the Giants will be looking to tee off on Flaherty, who has just one win to show for his last 11 starts and none in his last eight.
The 23-year-old's last five starts have been especially troubling, as he's gone 0-2 with a 7.82 ERA.
Flaherty has faced the Giants twice in his career, both times in San Francisco, without any success, getting bombed for eight runs and 13 hits in 6 1/3 innings. He was able to survive both starts without a decision while compiling an 11.37 ERA.
--Field Level Media