‹ BackHN Continuity

Thread

Commit description as a thinking tool

130 points · 78 comments · yedhukrishnan

  1. kccqzy · · focus · HN ↗
    Long ago I changed the default commit message to include headers “Why?” and “How?” to remind myself that I need to explain why a change is made (what this article focuses on), and how it is made (different implementation approaches considered). I followed this format for a long time. I was in the top 1% for commit message length at the company.

    Tangent: I once worried about things breaking when commit messages got too long. I tried really long commit messages and nothing broke: <a href="https:&#x2F;&#x2F;github.com&#x2F;kccqzy&#x2F;long-commit-messages&#x2F;commit&#x2F;ccfda400ebe0248ca4a37d1a087507c7dd455a3b" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kccqzy&#x2F;long-commit-messages&#x2F;commit&#x2F;ccfda4...

    1. sublinear · · focus · HN ↗
      To stay concise, I think bullet trees are the best. I&#x27;ve never had to make exceptions to this format.

      Top level groups high-level concerns (optional). Below that (required) are short distillations of those concerns answering &quot;why&quot;. Below that are descriptions of &quot;what&quot; was&#x2F;wasn&#x27;t done. A final optional level digs into deeper implementation detail.

      The vast majority of my bullet trees are just those two required levels. Each commit message is rarely more than 10 or 15 lines long, and people really appreciate them. I appreciate them too since I&#x27;m the most likely to read them.

      1. tommica · · focus · HN ↗
        Got an example of what you mean?
        1. sublinear · · focus · HN ↗
          A full example of all levels would be something like this. Generally, I think I&#x27;d have split up this commit to remove the top-level bullets, and more splits means fewer bullet levels.

          Also, due to HN comments not being the best with formatting this kind of thing, I kept these lines very short. It&#x27;s the gist that matters most.

          I don&#x27;t know where I picked up this style, but it was before I ever got hired anywhere. It was common across several places I worked at later on in the 2010s. I strongly prefer this to rambling prose. The first line is the Jira ticket description, by the way.

            MYPRJ-73: Auth bug redirect loop
          
            - Frontend router fixes
              - Check cookies before redirect
              - Default redirect to login page
                - New case added for &quot;expired&quot;
            - Backend
              - Update repurposed Apache config
                - Remove old DBM
              - Update cookie response header
                - Don&#x27;t use &quot;SameSite=Strict&quot;
                  - Removed 3rd-party lib
                  - We own this code for now
          1. tommica · · focus · HN ↗
            Interesting, thanks for sharing. Need to try it out!
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.