Yusmeiro Petit participant of 2012 Major League Baseball season
San Francisco Giants (2012–2015)
Petit signed a minor league contract with the San Francisco Giants for the 2012 season. He made his Giants debut as the starting pitcher on September 23, in place of Tim Lincecum, in a move to rest the regular rotation, since the Giants had clinched the NL West division title the day before. Petit allowed 2 runs and 7 hits in 4 2/3 innings in that effort; he was not the pitcher of record in a Giants loss. The Giants won the 2012 World Series over the Detroit Tigers and although Petit was not on the playoff roster, he did receive a ring.
Petit began 2013 with Triple-A Fresno, but on July 23, he was called up to help the pitching staff during a double-header. He pitched in the first game of the double-header after Eric Surkamp had a poor start. In 5.1 innings, he struck out 7 and gave up 2 runs. On July 28, he was designated for assignment. Petit subsequently cleared waivers and was sent back to Fresno. He was recalled by the Giants on August 23, as a starter.
On September 6, 2013, making just his third major-league start of the year since joining the rotation as an injury replacement, Petit came within one strike of pitching a perfect game against his former team, the Arizona Diamondbacks.  It was broken up on a single by pinch hitter Eric Chavez on a 3-2 count with two outs in the ninth inning. Petit would get the following out, finishing the game with 7 strikeouts and no walks on 95 pitches. The Giants won that game 3-0. The game was Petit's first career complete game and shutout. He was the 12th pitcher in MLB history to lose a perfect game with two outs in the 9th inning.
During the 2014 season, Petit worked mostly in relief, with occasional starts. Making a spot start in place of the injured Matt Cain on July 22 and giving up five runs (increasing his season ERA to 4.11), Petit recorded the last out of the fifth inning and subsequently proceeded to post six consecutive perfect relief appearances, of lengths varying from 1 to 4+1⁄3 innings, totalling 38 consecutive retired batters.  On August 28, Petit returned to the Giants starting rotation in place of Tim Lincecum and set down the first eight Colorado Rockies to set a new MLB record for consecutive batters retired at 46 (over a period of eight games), breaking the record of 45 formerly held by Mark Buehrle.  Buehrle's streak included his perfect game and the starts before and after.  Buehrle had broken a 1972 record of 41 consecutive retired batters that had been set by Jim Barr over the course of two complete-game wins, from the third inning of one to the seventh inning of the next; Barr's mark had been tied in 2007 by Bobby Jenks over the course of 14 relief appearances. He also broke Buehrle's record for consecutive perfect innings pitched by 0.1 with 15.1. After giving up a third-inning double to opposing pitcher Jordan Lyles to snap the streak, Petit proceeded to complete six innings, allowing four hits and a run, to record the win and reduce his season ERA to 3.44.In the Giants' 18-inning victory over the Washington Nationals in the second game of the 2014 National League Division Series, Petit pitched 6 shut-out innings in relief to get the win, as Brandon Belt hit the game-winning home run in the 18th.In Game 4 of the 2014 National League Championship Series, Petit pitched three scoreless innings in relief of Ryan Vogelsong that gave the Giants time to erase a 4-1 deficit.With the Giants' victory over the Kansas City Royals to secure the 2014 World Series title, Petit won his second world championship. He also became the only professional baseball player to win both the Little League World Series and the MLB World Series.