Since there are many opinions among git experts as to "how often should a commit be made?" we would like to contribute an opinion informed by modern tooling.


We propose that one commit should include only enough change to dash off a commit message that serves as an ad hoc "artifact of intent." Since it's easier to discuss things that have labels (shakes fist at Twitter's alter-ego), let's call this definition of commit strategy "minimalistic committing."



linkVs. Squash Commits

There is a contingent of programmers who advocate for the opposite of minimalistic committing: squashing commits. Perhaps the best argument for combining commits is that, if you're a auditing work by perusing a commit history, the more work gets stuffed into one commit, the better. In this world, "a commit" is tantamount to a "pull request," in that it's "what the reviewer needs to review."


With modern tooling, there is much less benefit than there once was to optimizing git commit history. If one wants to review groups of historical work, pull request history is already optimized for showing a history of what changed and why -- on the 1-5 day scale (usually a "manageable to review"-scale).


linkPull Requests and Commit Groups summarize units of work

If one wants to review work prior to a pull request, commit groups are your friend in the work grouping business. They can be grouped by configurable date & criteria. And you can always navigate back through the Commit Activity Browser to see patterns from previous eras of work.


With adequate tooling, commits can be grouped to whatever dimensions are expedient for the reviewer -- smaller or larger, by those that involve a migration, or a dependency change. I believe this negates most or all benefit from squash-adjacent commit strategies.


linkMinimalistic committing optimizes blame history

The benefit of minimalistic committing is that it allows commit messages to be more targeted to the one specific thing that changed in the commit. In tools like Gitlens, and GitClear's PR tool (on line hover), every line is summarized by the last commit message to have changed it. If a commit is supposed to combine more than one day of work, that figures to be a lot of information that will be included in the commit message. So, the user trying to understand why the change happened is going to be on the hook for more reading.


Will the "more reading" illustrate additional context? Yes, if the committer is lazy in writing commit messages. But, spoiler: all humans are as lazy as we can get away with. Writing one commit message per day means that you get one shot to be diligent. Writing 10 commit messages per day gives you 10 opportunities to be lazy. But, in the latter, at least you are guaranteed to write at least 10 things about "what you changed and why."


And, again, tools like Commit Groups will automatically aggregate commit messages, so if you write 10 things about the day, they will be collected into one summary of the day's changes and their rationales.


linkConclusion: Minimalistic committing benefits

Committer gets more save points to return to if they change their mind about the best course.

Managers don't need to interrupt developers (or hold regularly scheduled meetings) to know whether their team is stuck. When every developer is encouraged to push at least one commit per day, even if they are stuck or floundering, their team can see that they are trying to make progress. Knowing the in-progress ideas a developer is considering can be a great way for junior developers to get feedback before they make the (to a new developer, scary) leap to filing an official pull request.

Optimized git blame data. Tools like GitClear's Pull Request Review Tool can explain a concise reason why each line changed.

Historically, there have been good reasons to prefer that lots of work is packed into each commit, to keep each unit of git commit history substantial (hypothetically, to reduce likelihood that the code subsequently changed). With 2020's tooling, there are more reasons to prefer minimalistic committing than in previous decades.


linkPostscript / Minimalistic Committing example

As illustrated above, there is no single right answer to how commits should be authored. But here's a snippet of the author's recent commit history as an ad hoc demo of what minimalistic committing might look like in practice:


commit 95c05f2ccb7a11f285bd76a824a92b9cb35a321b (HEAD -> bh-review-tab)
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 22:03:18 2024 -0700
 
v1 question drag-to-reorder
 
commit 84e3c9f16aa9c9bd9a332d4fc0fce741ea23a711
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 21:31:15 2024 -0700
 
* Escape closes category
* Tidy question icons CSS
 
commit 96e0a540db7497cbbe7ce30de9f6ca781baa33d7
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 21:20:17 2024 -0700
 
* Group like functions
* Close category on click
 
commit eaa2058c945b7e59e4add8c6e870833103c08633
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 21:15:50 2024 -0700
 
#pub Customizable developer satisfaction surveys
* Move question data to elements so we don't have to pass massive JSON objects to unbounded number of components
* Show category of each chosen question
* Show error messages when creating poll if applicable
 
commit 9f3740a6485dfcccf9f45955282b3bc318811f2c (origin/bh-review-tab)
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 18:12:27 2024 -0700
 
Rename Dev Satisfaction tab to better abide the "Review" theme
 
commit a1c67a1ca17450f757f2d500a25f3714d5e251f6
Author: Bill Harding <wbharding@gmail.com>
Date: Tue 18:07:55 2024 -0700
 
Create standalone action for viewing team poll


Each commit has 1-5 items complete, plus incremental summary as needed to add baseline context.