Live data from Hacker News

How to write a Git commit message (2014)

cbea.ms

71–80 of 185 posts

Re: How to write a Git commit message (2014)

#71
I like this post. I know people are offering their alternative conventions which they have various rationales for preferring, but I've followed the conventions this post advocates for years, and they haven't done me wrong.

This post describes a widespread standard practice. People never complain about my commit messages and they don't have trouble understanding them.

Re: How to write a Git commit message (2014)

#73
post #2

I prefer Github's method of "git commit messages don't matter, pull requests do". Nowadays, you can easily enforce that the ultimate commit log looks rather nice by doing this: 1. Make it so the only merge strategy allowed on a repo is "Squash and Merge", so each PR = 1 commit in main branch 2. Have engineers care about the pull request quality rather than commit messages It's easier to be more expressive in a pull r…

For the code review step, sure, commit messages don't really matter unless your team reviews PRs commit-by-commit. How many times do you actually change the default squashed message? If you write a series of garbage commit messages, I don't particularly trust that you'll write a very good squashed message, either. How many times do people skip updating the PR description with new information or features from comments…

Everybody I've seen modifies the squash message in a professional setting. After all, that's the one that everybody else will see. Commits on your feature branch don't really matter and the entire branch can be deleted afterwards anyways

Re: How to write a Git commit message (2014)

#74
post #61

Earlier quoted context omitted.

Conversely I hate these with abundance. If you feel that working on your project is a chore, why are you still working on it?

I don’t particularly enjoy cleaning my house but I love the aftermath. Same with bumping versions on dependencies. If I didn’t have to do it I’d love to just get the new features in a non-breaking way. But I can’t, so I do, and it’s a chore.

Interesting viewpoint, thanks for sharing it. I disagree, but at some point it becomes a personal perspective, so ultimately a point of philosophy.

Re: How to write a Git commit message (2014)

#75
post #19

Earlier quoted context omitted.

> Having whitespace-altering "Dummy commit to trigger CI, ugh!" `git commit --allow-empty` may be sufficient for that "there is a new commit" trigger in many cases. If so, that may be preferable to whitespace changes as those clutter up the blame. As an aside, my initial commit on a repo is an empty one so that I can branch from a completely empty repo to do radical rewrites and yet maintain a history relationship wi…

> As an aside, my initial commit on a repo is an empty one so that I can branch from a completely empty repo to do radical rewrites and yet maintain a history relationship with that initial empty commit (which I feel is preferable to an orphan branch and then a merge with unrelated histories ... though those tell slightly different stories in the log). Oh cool, I thought I was literally the only person on the planet…

Starting a repo with an empty commit is a cool idea. My first commit has been "Add empty README" since forever, but I like your way better and I'm going to start doing that.

Re: How to write a Git commit message (2014)

#76
post #61

Earlier quoted context omitted.

Conversely I hate these with abundance. If you feel that working on your project is a chore, why are you still working on it?

It doesn't literally mean chore. It means a code change that you do regularly but is not major, and usually doesn't require much work (update dependencies being a good example). > Chore: A routine or minor duty or task Rather than > Chore: An unpleasant or burdensome task

> It means a code change that you do regularly but is not major

So "update". Attaching emotionally charged words like "chore" does nobody any favors, and in fact has negative consequences.

Re: How to write a Git commit message (2014)

#77
post #61

I like the conventional commit style [0]. You may have seen these in open source repos or used them at work. They look like feat: support new line chart fix: update props for new line chart chore: bump dependency version What's also cool is there are tools (semantic release) that will then handle automatically the versioning and publishing of your module based on these commits using the commit type (feat, fix, chore…

Conversely I hate these with abundance. If you feel that working on your project is a chore, why are you still working on it?

No post body was provided.

Re: How to write a Git commit message (2014)

#78
post #31

I hate that rule about 50 characters. IIRC, it started because someone noticed that the average commit message in the linux kernel is about 50 characters. Then, for whatever reason it morphed into this widely propagated mantra saying that the maximum should be 50 characters.

Indeed, I follow these rules but I routinely violate the 50 character limit. It's far more important for subject lines to be useful than to be maximally succinct; I'm not out here trying to write an essay in the subject line, but I do need it to be appropriately descriptive.

Re: How to write a Git commit message (2014)

#79
post #70
post #58

Earlier quoted context omitted.

I've been using github-changelog-generator [1] for (you guessed it) automatic changelog generation, which adds bug fixes/features to the changelog based on issues and PRs, but sematic-release looks like it might be even more useful. [1] https://github.com/github-changelog-generator/github-changel...

These "changelog generators" look to me like barking at the wrong tree, automation for the sake of automation, and attempt to skip the "boring" work of communicating changes by replacing it with "interesting" work of massaging git history, inventing microformats, etc. Why bother with separate changelogs at all then when you can see changes in `git log`. Just write good commit messages! /s

Well rather than manually enter the bug fixes/features introduced in each release on the GitHub releases, you can just paste a link to the automatically generated changelog. This is less error prone and isn't meant to replace writing good commit messages.

Re: How to write a Git commit message (2014)

#80
post #61

Earlier quoted context omitted.

Conversely I hate these with abundance. If you feel that working on your project is a chore, why are you still working on it?

It doesn't literally mean chore. It means a code change that you do regularly but is not major, and usually doesn't require much work (update dependencies being a good example). > Chore: A routine or minor duty or task Rather than > Chore: An unpleasant or burdensome task

Updating dependencies can be a major change. It can also be a security fix.

Marking it as a simple chore sounds like the impact has not been fully analyzed.

I understand the practice and if done meticulously by all contributors, it should at least signal a well organized project but most of the time, it just shovels your entire commit log as a release notes. It's OK to have it, but I much prefer projects that takes time to summarize the impacts to their users.

Post reply on HN