
In common American editing style, use that for a clause that identifies which thing you mean. Use which with commas for a clause that adds a detail about a thing already identified.
See how the clause changes the meaning
- Identifying detail. The jars that have green lids are ready to ship. The clause limits the statement to jars with green lids. Leave out the commas.
- Added detail. The jars, which have green lids, are ready to ship. All the jars under discussion are ready. The commas mark the detail that they have green lids.
Check what happens when you remove the clause
Remove that have green lids from the first sentence and you lose the information that limits which jars are ready. Remove which have green lids from the second and the same jars are still ready.
Identifying which without commas is also grammatical, especially in British English. Follow your style guide if it prefers that. Read Relative Clauses for the full pattern and Punctuation for how commas guide readers.