Nori Aoki, Matt Duffy and Brandon Crawford each drove in runs for the Giants, who continue their seven-game road trip to begin the season with a stop in San Diego on Thursday.
Chris Heston (1-0), making his second career start, picked up his first MLB win after going six innings and allowing two unearned runs with five strikeouts.
Jeremy Hellickson (0-1) pitched 4 1/3 innings for Arizona and was charged with three runs on nine hits and two walks.
"I don't think any of his location was any good," D-backs manager Chip Hale said of Hellickson's outing. "I think (the staff) is amped up a little bit."
Chris Owings knocked in a run for the D-backs, who welcome the Los Angeles Dodgers to the desert for a three-game set on Friday.
San Francisco loaded the bases with one out in the first after a hit, an error and a walk. Hellickson worked out of the jam, however, striking out McGehee and getting Justin Maxwell to ground out to end the frame.
Owings opened the scoring with an RBI groundout that scored A.J. Pollock in the home first. Pollock reached first after getting hit by a pitch and moved to third on Heston's error on a pickoff attempt.
The Giants responded in the second with Aoki driving in Crawford with a double prior to Duffy's run-scoring double.
Crawford then singled home McGehee in the fifth for a 3-1 game. Paul Goldschmidt cut the D-backs deficit to one when he scampered home on Hector Sanchez's passed ball.
Santiago Casilla came on in the ninth and recorded his second save of the season.