I did not really know the difference, until I started reading the book
On Writing Well. The author William Zinsser writes:
William Zinsser, On Writing Well - 6th edition %} If your sentence needs a comma to achieve its precise meaning, it probably needs “which”. “Which” serves a particular identifying function, different from “that”. (A) “Take the shoes that are in the closet.” This means: take the shoes that are in the closet, not the ones under the bed. (B) “Take the shoes, which are in the closet.” Only one pair of shoes is under discussion; the “which” usage tells you where they are. Note that the comma is necessary in B, but not in A.
He also adds that in most situations, “that” might be the correct choice.
I never bothered to learn the difference before, did you?