If your not using source control for your coding projects, get off my lawn. 😛 (#JustHadToSayIt)
Now that I’m only reaching people who use source control (serious developers), I’d like to ask that you focus hard to only commit changes that belong to a single topic at a time. Think SRP for code commits/check-ins.
What is a topical commit?
That almost looks like ‘tropical’ and wouldn’t it be nice to be in a tropical place doing commits to your code, but I digress…
The topics I’m referring to are specific functional units of change where each tiny commit is related to a single topic or theme.
- adding feature X
- bug fix
- spelling fix
- Updating comments/documentation
- *** code formatting ***
I highlighted that last one for a reason as it’s the impetus for writing this post.
Don’t mix topics/themes within a single commit!
Instead break them into multiple commits. If you’re using git, checkout ‘git add -p‘
If you have a one line bug fix but the file has 20 lines of code formatting changes (you know who you are). It makes determining what the bug fix is nearly impossible from the changes that are code formatting.
Using tools like git bisect to look at history become difficult. Pull Requests in GitHub become difficult to understand. If you’ve left a codebase for a while and come back, try reading changes that have happened over time to get caught up can be extremely difficult to do if your commits are not topically based.
Let’s just NOT mix topics in our commits, ok?
K, THX bye!