SAN FRANCISCO -- J.T. Realmuto matched his career high with four hits, including a tiebreaking home run in the eighth inning, and the Miami Marlins beat the San Francisco Giants 5-4 on Sunday to avoid a three-game sweep.