There is a comma before but when there is an independent subject and verb after.
...was here, but she could not stay long...
...was here but could not stay long...
...wrote her, but I wasn't sure of her position...
...wrote her but wasn't sure of her position...
A contrasting element begins with not, never, seldom, or rather. A contrasting element is a result of our tendency to cut the language down once we have established a pattern. A contrasting element is separated from the rest of the sentence with a comma.
...He was leaving on Friday; he was not leaving on Saturday.
...was leaving on Friday, not Saturday...
...She was hired in January; she was not hired in December.
...was hired in January, not December...
If we inset a but in these sentences, the comma goes away because the but does not have a subject and verb after it.
...was leaving on Friday, not Saturday...
...was leaving on Friday but not Saturday...
...was hired in January, not December...
...was hired in January but not December...
Happy punctuating!
Margie