Petit replaced scheduled starter Matt Cain, who cut his hand on a knife in the kitchen at AT&T Park just before batting practice, and held the Padres to three hits over six innings of a 6-0 win over the Padres.
Angel Pagan and Buster Posey each hit home runs in the first inning and Hector Sanchez had three RBIs to back the clutch emergency start.
"I'm prepared for it at any time," Petit (2-1) said of his 45th career start. "Even if it's one moment before the game."
Petit, who didn't walk a batter and faced just two over the minimum, went to a three-ball count twice in the game and threw a first-pitch strike to 15 of 20 batters.
"He's the perfect guy for the situation," Giants' relief pitcher Jeremy Affeldt said. "That's his makeup. He threw four innings in Colorado and saved the bullpen. Tonight he went above and beyond the call of duty."
Petit, who threw a one-hit shutout against the D-backs on Sept. 6 last season, was impressive in his first start of 2014. He retired the first nine hitters he faced and allowed one baserunner past first base.
"What a great effort," Giants manager Bruce Bochy said. "To lose the starter and to get six innings like that really lifts the ballclub. We saw him pitch like that last year. It's sure fun to watch."
San Diego manager Bud Black wasn't having nearly as much fun.
"I don't know this fellow, but I assume it didn't faze him," Black said. "Based on looking at him from the other side, he looks calm and poised. This guy's a Major League pitcher and he pitched a good game."
Black said he was informed of the pitching change during batting practice.
"There's a good hour for our players to readjust," he said. "That's part of what players do -- constant mental adjustments as the day unfolds. Players are conditioned to adjust on the fly. We've faced Petit before. He's been around the league for over three years. Our guys know who the opposing pitchers are."
Petit said he had not thrown in a bullpen session since last pitching eight days ago. He did play catch every day to stay ready.
"By the third inning, I was letting it go," Petit said. "I felt good. I was only worrying about throwing the right pitch at the right time."
Giants pitchers retired the final 11 batters they faced in succession. Jean Machi struck out one in two perfect innings, and Santiago Casilla struck out one while working the ninth.
Pagan hit a 1-1 pitch by Eric Stults (1-3) just inside the foul pole in left field. Posey hit the first pitch he saw into the left-field bleachers. It's the first time the Giants have hit two home runs in the first inning at home since Fred Lewis and Bengie Molina did it against the Washington Nationals on July 22, 2008.
"That helped me relax," Petit said.
The Giants added three runs in the third when Sanchez singled home two and Brandon Crawford, who is hitting .440 (11-for-25) against left-handers, drove in a run to end Stults' night.
Sanchez added a sacrifice fly in the fifth. He has a combined eight RBIs in his last two starts.
Bochy said Cain is likely to be ready for his next start, which would come Monday in Pittsburgh.
Cain said he would probably delay throwing in a bullpen session an extra day to allow the finger to heal.
If Cain is unable to take his next turn, Bochy said he can always turn to Petit again.