commit messages are optional

· #programming

when you’re working on a branch in git you might commit your work for a variety of reasons, and git expects you to write a message every time.

this is a big ask for the commits that don’t make it into the trunk. it’s a chore to annotate snapshots that only get garbage collected.

for years i thought my options were:

  1. write something useful as reference
  2. write a trash message

but turns out there’s a third option: write nothing with --allow-empty-message -m "". these days it’s my go to.

i have this aliased to ‘cc’

git config --global alias.cc 'commit --allow-empty-message -m ""'

the odd time i do realize i want a message to refer back to i’ll add one on using git amend.

once i’m ready to merge my branch, i write a proper commit message.11 tim pope’s ‘A Note About Git Commit Messages’ being the canonical reference. i also remember someone suggesting that commit messages should say why you made the change (which can’t necessarily be derived from the diff) and that stuck with me either after squashing the commit with an interactive rebase, or more often these days in github’s pull request before a squash and merge.

i hope to see changesets in github one day. i think that would be a great place to write something.