"There must have been a home run derby I didn't know about," Bumgarner said.
Peralta's homer was his second this spring, one more than he has hit in 133 regular-season at-bats as a professional. He also homered last week against the Padres. Gomez's homer was his third this year. Martin Maldonado added another solo shot, off Giants reliever Javier Lopez, in the eighth.
On the mound, Peralta allowed one run on six hits in 6 1/3 innings, with no walks and five strikeouts. He is currently pegged to start the Brewers' fifth game of the regular season.
Bumgarner's next start will be the first of his career on Opening Day. He was charged with three earned runs on five hits in 5 2/3 innings, with no walks and six strikeouts. The left-hander will face the D-backs on Monday night at Chase Field.
Buster Posey and Michael Morse had two hits apiece for the Giants, with Morse's RBI single in the third inning giving Bumgarner a lead. Pablo Sandoval homered leading off the eighth inning to cut the Brewers' lead to 3-2, but a further Giants rally was scratched when Gregor Blanco, trying to stretch a single into a double, was thrown out by Brewers right fielder Ryan Braun.
The Giants tied the game with four straight hits off Wei-Chung Wang in the ninth, with Juan Perez and Gary Brown each driving in a run. Mark Minicozzi then hit a sacrifice fly to plate the go-ahead run.
Up next: Yovani Gallardo will face the Indians in Goodyear on Wednesday in the final tuneup before his fifth consecutive Opening Day start. No Brewers pitcher has ever worked five straight season openers, though Ben Sheets pitched six total over seven years in the 2000s. Gallardo has been sharp this spring, posting a 2.45 ERA and 14 strikeouts versus two walks in his five Cactus League starts.
Adam McCalvy is a reporter for MLB.com. Read his blog, Brew Beat, and follow him on Twitter at @AdamMcCalvy. This story was not subject to the approval of Major League Baseball or its clubs.