San Francisco matched its season-high with eight runs at home and avoided a series sweep by Los Angeles.