What should I commit?¶
A commit should represent a unit of work.
If you've made changes that represent multiple units of work (e.g., changing how input data are processed, and adding a new model parameter) these should be saved as separate commits.
Try describing out loud the changes you have made, and if you find yourself saying something like "I did X and Y and Z", then the changes should probably divided into multiple commits.
A helpful guideline is "commit early, commit often".
Commit early¶
-
Don't delay creating a commit because "it's not ready yet".
-
A commit doesn't have to be "perfect".
Commit often¶
-
Small, focused commits are extremely helpful when trying to identify the cause of an unintended change in your code's behaviour or output.
-
There is no such thing as too many commits.