Corollary: write the commit message first, implement things later! Not a joke, this is almost like TDD works. (TDD writes formal tests, which is much more involved.)
Documentation-driven development.
Second this. After having a chat with some coworkers, I've been attempting to write more thoughtful and longer commit messages. I had this exact experience yesterday after I had staged my commit and was writing the message. I realized that there was a better way to do this change and redid the whole thing.
(Aside: you should probably write longer commit messages.)