General manager Bobby Evans confirmed the deal Thursday. Cabrera is scheduled to join San Francisco's Arizona rookie league team initially then move on to Triple-A Sacramento when ready, Evans says.
The 28-year-old Cabrera appeared in 29 games for Baltimore this season, batting .208 with a pair of doubles and four RBIs before his release last month.
He spent the previous six seasons in the NL West with San Diego regularly facing the reigning World Series champion Giants, who also won titles in 2010 and `12.
Cabrera was suspended by Major League Baseball for the final 50 games of the 2013 season for violating the sport's drug agreement in relation to its Biogenesis of America investigation.