Remember this to remember the difference : ‘that defines, which describes’.
‘that’ introduces an ESSENTIAL DEFINITION of the subject, while ‘which’ introduces an OPTIONAL DESCRIPTION of it. The following two sentences illustrate this nicely:
He stopped the first car that was driven by a woman.
He stopped the first car, which was driven by a woman.
First sentence means that he did not stop any car that was not driven by a woman. He stopped the first car which he found was driven by a woman
Second sentence means that he stopped the first car that he came across. Then it gives an optional information that this particular car was driven by a woman :)
In the first sentence, ‘that’ introduces an essential definition. Without the rest of the sentence, the meaning is completely different. But in the second, ‘which’ introduces a description, without which the sentence would still have the same meaning.
Note also that ‘which’ always follows a comma, while ‘that’ runs straight on. The comma denotes a pause in speech, as you can confirm by reading out the two examples above. So you can always say your sentence out loud, see if a pause is needed, and make your selection on that basis. (If you pause, there’s a comma and therefore it’s ‘which’.)
More info here :)