Changesets are the heart of any version control system, and making good changesets is vitally important to the maintainability of your code. As all code on WordPress.com VIP is reviewed by a real person, it’s even more important all changesets are well crafted.
Remember – always code (and commit) for the maintainer.
A Good Changeset:
Represents one logical change
What comprises a “logical change” is up for interpretation, but only directly related changes are included. Generally, the smaller the changeset, the better.
Good Example: Adding the CSS, JS, HTML, and PHP code for a new UI button.
Bad Example: Adding the new UI button, fixing whitespacing, and tweaking copy in the footer.
Bundles related changes together
It’s much easier to trace refactorings and other changes if related changes are grouped together. Rather than splitting a logical change into many separate commits, related changes should be combined.
Good Example: Refactoring code into a new plugin by moving it to a new file and including that file.
Bad Example: Refactoring code into a new plugin by putting the code removal, addition, and include into separate commits.
An atomic commit means that the system is always left in a consistent state after the changeset is committed. No one commit would cause the codebase to be in an invalid state. The commit is easily rolled back to a previous valid state, including all related changes, without the need to analyze the potential interdependencies of neighboring commits.
Good Example: Adding a new feature to the homepage by committing the HTML / PHP changes alongside the required CSS / JS changes, so there is never an incomplete state (HTML elements without styling) in the codebase.
Bad Example: Committing the HTML changes and requisite CSS / JS separately. The first commit represents an inconsistent state, as the feature can exist in the DOM without being properly styled.
Is properly described
Accurately describing the changes is very important for others (and future you) looking at your code. A good commit message describes the what and why of a change. Please see How to Write a Good Commit Message for more information.