Gallardo, who will be making his third straight opening day start for Milwaukee at home against St. Louis, outlasted Lincecum and the Giants in Milwaukee's 7-4 win on Sunday.
Gallardo allowed four runs and eight hits with a walk and seven strikeouts in 5 2/3 innings.
Lincecum gave up six runs and eight hits for the Giants. He walked one and struck out four in 4 2/3 innings. He also went 2 for 2 with an RBI.
"He (Gallardo) was really good, then a little off, really good, then a little off. He was up and down. He lost his command a little bit," Brewers manager Ron Roenicke said. "He needs to be consistent, keep it every single inning."
Despite the inconsistency, Roenicke said Gallardo is ready to go against the Cardinals.
Gallardo gave up a three-run homer to Brandon Crawford in the second inning, then settled down.
The Giants scored in the fourth when Lincecum got his second hit, showing bunt and then chopping the ball over third baseman Aramis Ramirez for an RBI single.
"Honestly, I gave up those four runs, but I felt like my rhythm was the best it's been all spring," Gallardo said.
He has been working on it all spring.
"That's where it all starts for me," he said. "I want to stay together, balanced throughout my whole mechanics. Once I start rushing or slowing down a little bit is where I get into trouble, and the ball doesn't explode out of my hand. Today, the mechanics were finally were where they were supposed to be."
Lincecum was focused on Friday's start.
"The location was good, the best my fastball location has been all spring," he said. "Regardless of the outcome, I feel good coming out of it.
"I am ready to get back out there and pitch a real game, pitch with a purpose."
He said his run-scoring hit was lucky.
"I was hoping it would stay fair," he said. "We (pitchers) work on our hitting ... every at-bat is important, and we take it seriously."
Roenicke has been impressed with the play of free-agent veteran shortstop Alex Gonzalez this spring.
Gonzalez had two hits to raise his spring average to .440 and was in the middle of a key double play, making a throw to get Gregor Blanco at first to end the fourth.
Brewers right fielder Corey Hart might be activated for opening day after recovering from arthroscopic knee surgery. He likely will have a light workout day on Monday and then play in games on Tuesday and Wednesday, giving him approximately six more at-bats. "We want to be smart about it," Roenicke said. Closer John Axford picked up the save for the Brewers on Sunday, but Roenicke said he still is trying to find his command. ... The Giants head back home to the Bay Area for a three-game Bay Bridge series with Oakland before returning to Arizona.