Here's a breakdown:
* Independent clause: A group of words with a subject and verb, expressing a complete thought.
* Comma before "but": Used to separate two independent clauses joined by a coordinating conjunction like "but," "and," "or," "nor," "for," "yet," or "so."
Example:
* I love to cook, but I hate cleaning up afterwards.
Here's why the comma is necessary:
* "I love to cook" is a complete thought.
* "I hate cleaning up afterwards" is also a complete thought.
* "But" connects these two independent clauses.
When you don't need a comma before "but":
* When "but" connects a dependent clause to an independent clause. A dependent clause needs an independent clause to be complete.
* When "but" is used within a single independent clause.
Examples:
* I love to cook but I don't have much time to do it. ("But" connects a dependent clause to an independent clause.)
* I love to cook but only certain dishes. ("But" is part of a single independent clause.)
Remember: If you're unsure whether to use a comma, read the sentence aloud. If there's a slight pause before "but," a comma is likely needed.