The deal Wednesday includes a spring training invite to big league camp with the World Series champions.
The 31-year-old Hernandez hit 15 home runs last season while batting .234 with 40 RBIs in 142 games for San Francisco. In 2017, he didn't hit a homer in 310 at-bats.
The Giants recently opted not to offer Hernandez a contract for 2019. New Giants president of baseball operations Farhan Zaidi said earlier this week at the winter meetings that his club was looking for an improved combination of on-base percentage and power in the outfield positions.
Hernandez has previously played for Pittsburgh and Miami.