It is established that each individual Git commit should be a single logical change. It is also established that this production process is often messy (see sausage-making) and should not be hidden away - Seth Robertson advocates "Commit often, perfect later".
I find that at some point, either at the end of a project or at the end of a series of related commits, I need to tidy my code, especially if I have been engrossed in a problem and working quickly. By tidy I don't mean logical changes that affect the actual workings of the program, but rather things like:
- Clarifying comments
- Changing the order of functions to improve readability
- Correcting indents/whitespace
- Deleting old tests like
// console.log(variables)
My question is then: is it best practice to save these 'cosmetic' changes in a separate individual commit? (And if not how should they be committed?)
Note that I'm not inviting opinion on this. Surely there is an established best-practice; the article above emphasises enforcing standards, so it's important to know what those standards are.
As well as Seth Robertson's article I've read the following existing questions, but I can't find my question addressed anywhere: