Better Commit Messages
Going through my TL saw the below tweet, I felt attacked a bit. As a one man army on most of my projects, I alway...
For further actions, you may consider blocking this person and/or reporting abuse
"Quick Fix" FTW!
"Fixed quick fix" =D
Fixed quick fix fix :V!
I didn't realize you could even make a template. Maybe now I won't forget to add some more content.
I didn't either, is incredibly crazy how configurable git is. 😁
It is actually pretty useful.
Now I use it all the time
What worked for us and I see it in many Github repositories is the Angular commit convention.
You can read about it in the Angular contribution section or in the conventional commit description
In general I make small commits which solve one issue / task and aim not to mix up code refactoring with the actual task. In most cases a one liner is totally enough then. I also add the ticket number to get background information if necessary. In case it's a bug fix for a regression I add the commit hash that introduced it.
The one liner, ticket number and commit itself is fine for me. Yet this requires to set proper messages and a good maintained ticket.
Thus, tbh I sometimes catch myself not doing it. If possible I fix things by using the interactive rebasing then.
Bottom line, as of now I am not using templates.
Yeah everyone got a different workflow. You can add a one liner template to remind you too. 😉
git commit -m 'changes'
😂This is pretty cool!
But I'd still prefer doing one line commit messages.
I try hard to make my code speak for itself. But whenever I really need to explain the whys, I put it in the ticket discussion or in the pull request.
Code speaks to you and only you. Even then after a few months maybe not even you lol.
Do you know if discussions are pulled once PR is merged?
You could follow 50/72 format in your commit messages
stackoverflow.com/questions/229001...
If you really want to you could use emoji's gitmoji.carloscuesta.me/
Thanks for the tip!
I think templates per project can be a good idea, to make sure everyone meets the project guidelines, and to be a prompt for better messages. Otherwise if to in a hurry to get a patch out, then you'll make a crummy, no value message like 'fixed the fob'
I generally make commits that follow the guidelines from GitHub with one line, 50 char subject summary, then a blank line and more verbose summary, wrapped at 72 chars, with link to ticketing system or GitHub/GitLab issue for the full explanation. This plays well with editor tools like Magit (Emacs) or GitLense (Code), or git blame, which show just the first line in summaries or logs, but can expand our pop up the full commit message.
"X fixed"
"Forgot to remove prints"
"Forgot to remove the last print"
Very clever way to enforce convention on those meaningless commits messages! Great for people like me who use git blame viewer (I use GitLens on VSCode).
We use one line commit messages on conventional commit style, then we create detailed PRs with detailed problem and solution sections. The structure of the PT is defined in guthubs or template.
Yeah a very high percentage of repos don't implement templates unfortunately.