News for hackers. Stuff that matters.
Re:Using Git commit message templates to write better commit... by TAKEMYMONEY on Wednesday January 12, 2022 @04:49PM (#29913179)
A noble effort but in my experience these just get ignored. 90% of the PRs at my org have the empty, unfilled template text at the top of the description, a few line breaks, and then the actual description underneath.
Re:Using Git commit message templates to write better commit... by yakshaving_jgt on Wednesday January 12, 2022 @04:57PM (#29913276)
That's unfortunate, and I think your experience reflects most places I've worked at too. It doesn't have to be that way though; technical leadership on a team can choose to care about this kind of thing and coach their colleagues into caring more about writing communicative commit messages.

To any technical leaders reading this comment, I encourage you to choose to care about this :)

Here's the post I always share on this: https://tbaggery.com/2008/04/19/a-note-about-git-commit-mess...

Re:Using Git commit message templates to write better commit... by jasonpeacock on Wednesday January 12, 2022 @05:30PM (#29913659)
1. Implement automation to flag and block/reject bad commit messages.

2. Educate and train ppl to include commit messages when they do code reviews

or 3. give up and move on because your org doesn't care.

Because this is a culture (not code) smell and changing culture is hard and needs support from the top.

Re:Using Git commit message templates to write better commit... by toomanybeersies on Wednesday January 12, 2022 @11:30PM (#29916886)
> Implement automation to flag and block/reject bad commit messages.

They'll just use `git commit -n` to skip the pre-commit hook.

And if it's verified in CI (e.g. with Danger), someone will just create a script to automate writing commit messages that pass the good commit message test.

Re:Using Git commit message templates to write better commit... by jasonpeacock on Thursday January 13, 2022 @12:39AM (#29917242)
And those are the people you fire because they refuse to follow policy and actively work to circumvent best practices and quality gates.
Re:Using Git commit message templates to write better commit... by hackerbrother on Wednesday January 12, 2022 @09:11PM (#29915960)
No way, (1) would annoy the heck out of people. Plus what if you want to just save off your current status and log off for the day..
Re:Using Git commit message templates to write better commit... by jasonpeacock on Wednesday January 12, 2022 @10:06PM (#29916322)
Configure the enforcement only for `main` and other release/production branches, let people push whatever they want to their dev/feature branches.

When those branches are attempted to be merged they'll fail due to having bad commits and require fixing.

Re:Using Git commit message templates to write better commit... by blindmute on Thursday January 13, 2022 @09:11AM (#29920889)
That's what git stash is for; you can even add a message, just like a commit, to the stash. A commit should always be in a good state, runnable, without lint or other errors.
Re:Using Git commit message templates to write better commit... by icedchai on Thursday January 13, 2022 @07:18AM (#29919935)
Yes. In my experience, anything that prevents people from committing to local branches is incredibly annoying. You want people to commit frequently and “save their work.” Checks, quality barriers, etc. are fine at CI time.
Re:Using Git commit message templates to write better commit... by toomanybeersies on Wednesday January 12, 2022 @11:24PM (#29916852)
> Plus what if you want to just save off your current status and log off for the day

Strictly speaking, that's what git stash [1] is for. Not so ideal if you want to push your WIP changes to Github though.

[1] https://git-scm.com/docs/git-stash

Re:Using Git commit message templates to write better commit... by gaoshan on Wednesday January 12, 2022 @05:24PM (#29913589)
We immediately kick them back if this is the case.
Re:Using Git commit message templates to write better commit... by bpodgursky on Wednesday January 12, 2022 @07:55PM (#29915325)
I always take care to delete the template text first.
Re:Using Git commit message templates to write better commit... by cerved on Wednesday January 12, 2022 @06:24PM (#29914255)
fwiw, the template text in this case are comments so that gets stripped