'Which' is used when the phrase is not necessary to identify the main subject, but rather just adds information.
'That' is used in a restrictive sense - we must have the phrase to help identify the subject.
"That was the car that hit us." - we need the phrase "that hit us' to identify the car.
"His car, which he has driven for 10 years, is in need of repair." - We know the car is his car. That phrase identifies it and is necessary. "Which has has driven for 10 years" just adds extra information.