Live data from Hacker News

The Lost Art of Commit Messages

seyhan.me

21–30 of 61 posts

Re: The Lost Art of Commit Messages

#21
post #8

Depends. Sometimes a one-liner or a reference to a ticket is enough. There are times when I make a one-line change and write a paragraph or two explaining why it had to be done. But these kinds of things often drown in the noise of a dozen other changes. If that one was important enough, I will reference it in an ongoing discussion or documentation, or at least include "read below:" on the first line. I usually see p…

A one-liner: sure. A ticket? No; ticket systems are transient and not always available. You shouldn't need to open an external system that may no longer exist in 20 years time (for example) to get the full context.

Compare the Linux commit history, every commit has its full context and explanation and they do not rely on external systems.

Re: The Lost Art of Commit Messages

#22
> Commit messages are the narrative of your project's history. They help others (and your future self) understand why changes were made, making collaboration smoother and debugging less of a nightmare.

Yes. And yet:

> - Keep each point brief and focused.

> - Use bullets (-) and avoid lengthy explanations.

No, they lost me there. You often can’t tell the necessary narrative in a single sentence, and you frequently can’t explain why changes were made briefly, and I strongly refute that “avoiding lengthy explanations” should be a goal in commit messages.

I exceed ten lines very frequently, and when working professionally I’ve tended to exceed fifty lines at least twice a year. Coworkers have commented favourably on my commit messages, as unusually useful, and some have even lengthened theirs more often after experiencing them.

I don’t know what my record is, but it was more than 300, though that was as part of a long-lived refactoring branch that I was needing to rebase every week or two for six months as I continued working on it, migrating from an in-house concatenation-and-#ifdef module builder to ECMAScript Modules, and I was maintaining the dozens of commits meticulously, some regenerated automatically and some requiring manual effort, and so I was detailing the semantics of the changes across a large number of files, so it might not count quite so much. But I’ve done over a hundred a few times for other reasons. Keep your mind open, and look at the longest commit messages in popular repositories, and you’ll find there’s a lot of scope for very long commit messages.

—⁂—

I loathe Conventional Commits. It saps the art out of the commit message, the tags are frequently badly applicable, the benefits are negligible to negative (changelogs shouldn’t be generated from commit logs—they should be their own thing), and they’re simply ugly.

Re: The Lost Art of Commit Messages

#23
What about Gitmoji? [0] Didn't get much love when discussed here[1] but fun concept. At least it makes you think about the commit message, which is better than not. And each commit having one selected emoji forces you to make one commit per improvement, so you can't bundle stuff together.

[0]: https://www.bekk.christmas/post/2019/11/gitmoji-yay-or-nay [1]: https://news.ycombinator.com/item?id=21760021

Re: The Lost Art of Commit Messages

#24
I quite like my current system.

One word naming the topic or area or system that was changed, then colon separated with a very short sentence giving a summary of the changes, then two lines later (if necessary), a bullet point list of the most important/noteworthy changes, then an explanation for why a thing was changed (if any change in the commit warrants it).

Honestly, I know most people won't go beyond the first line, but I do find the rest of it very helpful for my own work if I have to go through the commits sometime in the future.

It also helps that most of it is optional and I decide on a case by case basis whether just the first line is sufficient or I need the whole thing.

I see in the comments people questioning the purpose of a bullet point list, but it actually is helpful. I don't want to have to check the diff for every single commit if I don't have to. It's time consuming. If a commit message can tell me immediately if it touched something I'm interested in, that's a big time and effort and mental bandwidth saver.

Example:

auth: Refactored and fixed edge cases

- Fixed incorrect handling of token groups

- Added role enum to replace static strings

Re: The Lost Art of Commit Messages

#25

I rarely read the commit messages. It's often faster to just read the code than an obscure description, I'd rather have a small sentence that summarizes what the diff is doing than a technical paper explaining every change in the commit. I don't read pass the title.

Sure, but in bigger projects there's going to be thousands of commits and hundreds of thousands of lines in a diff; reading code becomes infeasible then.

But it's the only way if there's no commit message discipline, and even if there is it'll be difficult.

Re: The Lost Art of Commit Messages

#26
post #10

You get some of this for free if you create branches and squash merge them when finished. Without needing to think much about commit message, just a few words per commit is enough. This is good enough for me and I don't need to waste any time thinking about it. Example commits of something I worked on a few days back: $ git l feature/character-selection c54825f 3 days ago Robert Schaap (feature/character-selection) S…

Granted, I'm not the target audience of your commit messages, but they tell me very little about what happens. > Add characters I can probably tell from the code that that's what's happening. But what requirements drove these particular characters? > Remove old character What makes it old? How would I recognise an old character in the future? > Show male in editor Why did male not show before? Was there a bug or a pa…

Yes! Please tell me _why_ the commit happened. The _what_ is in the diff, so almost no need to tell me in the commit message. Often I get commits with some LLM-generated slop in the commit message. It always looks good and always tells nothing. Commit messages like that are garbage.

Re: The Lost Art of Commit Messages

#27
I'd also consider that this will become increasingly important in the age of LLMs. Want Cursor to one-shot a change? Dollars to donuts the agents of the future will perform a lot better with well-reasoned, well-documented commits to use as reference.

On the other hand, job security?

Re: The Lost Art of Commit Messages

#28
I second the Angular-style git commit message convention (https://github.com/angular/angular/blob/main/contributing-do...). Though, it is also art that I have lost.

On a lighter note, I recommend "8 Types of Commit Messages That Show He's NOT the Man for You" https://web.archive.org/web/20210606005031/https://www.codem...

Re: The Lost Art of Commit Messages

#29
post #8

Depends. Sometimes a one-liner or a reference to a ticket is enough. There are times when I make a one-line change and write a paragraph or two explaining why it had to be done. But these kinds of things often drown in the noise of a dozen other changes. If that one was important enough, I will reference it in an ongoing discussion or documentation, or at least include "read below:" on the first line. I usually see p…

A one-liner: sure. A ticket? No; ticket systems are transient and not always available. You shouldn't need to open an external system that may no longer exist in 20 years time (for example) to get the full context. Compare the Linux commit history, every commit has its full context and explanation and they do not rely on external systems.

[deleted]
Post reply on HN