Here's a breakdown:
When to use a comma before "but":
* When "but" connects two independent clauses: An independent clause can stand alone as a sentence.
* Example: I love to cook, but I hate cleaning up afterwards.
* When "but" introduces a contrasting element within a longer sentence:
* Example: He was a talented musician, but he never pursued a career in music.
When not to use a comma before "but":
* When "but" connects two dependent clauses: A dependent clause can't stand alone as a sentence and usually starts with a conjunction like "because," "although," or "since."
* Example: I want to go to the concert, but I can't afford a ticket.
When to use a comma after "but":
* Never! You don't use a comma after "but" unless it's part of a list.
* Example: I like apples, oranges, and bananas, but not grapes.
Key Point: The rule of thumb is to use a comma before "but" when it connects two independent clauses, but not when it connects two dependent clauses.