Why you should use a terminal editor to write a commit message
joaomagfreitas.link
joaomagfreitas.link
I use an editor to write commit messages because it lets me take my time, to format them, to edit them after the initial draft.
If I know the message will be under 50 characters, I might use `-m`, but the rest of the time I want an editor.
Always relevant: https://cbea.ms/git-commit/
4. Pre-commit hooks are an anti-pattern. The repo creator has no business messing with my local, half-broken experiment/exploration commits. Do that on push if you must.
5. The dual: oh, you passed the wrong flags to commit and you remembered this after you started to write the commit message? Too bad, the mess is yours to fix now.
The one reason that completely convinces me is 3. It's not worth the pain to enter a multi-line commit on the command-line. -m is for one-liners.
Git hooks are not part of the version controlled repository so you can already set them to whatever you like (for anything executed local anyway, push hooks are up to the remote).
You can also bypass them using --no-verify for cases where you consider that to be the right thing to do.
1. err, firing up an editor, type the message, save and quit is not quicker...
2. on my keyboard they are on a single key (I have inverted number/symbol row), my environment (Emacs/EXWM for some things my QMK firmware) automatically pair relevant symbols)...
5. various shells have history, easy navigation etc, so well... Not that hard...
6. I hardly imaging putting special chars in a commit message...
To me the main reasons might be: commit messages should often have a short line title THAN a more broad prose, witch is a good reason to use an editor. If your editor is not nano but something more featuresful you might like templates and so on. The rest seems to be a bit... Considerations by someone who not use much a shell, so it's not comfortable with it.
I continue to see commit messages by people using IDEs that have long single line commit messages.
A short summary line, which shows as the one line commit message in gitk et al, then a detailed commit messages that can be pages long in some cases is the ideal form.
Some commits only need a 1 line message, but others need long detailed blocks of text. When this is the case, having that short summary, and a blank line separating the lengthy details gives correct presentation in all git tools.
Please do! Context not included in the commit message or the code is lost forever.
How to Write a Git Commit Message: https://cbea.ms/git-commit/
... if you use a gui in front of git :)
Other than that, this feels over the top, to the point of satire on opinions in tech?
If typing two extra characters actually does cost you valuable time then you possibly need to reevaluate your work pressure or possibly amount of commits.
If you have trouble finding quotes on your keyboard, your blind typing skills just suck. Also, what language are you even coding in?
Remembering to not press enter is on the same level as learning to use nano (use vi you peasant!).
I guess some of the arguments are valid... in some environments.
:au BufWritePost * !git commit -a -m “Automatically commit crimes against my git history”
Or something like that- The first two reasons are quickly invalidated once muscle memory is in place.
- I rarely break line and keep my commit messages short, but that depends of your workflow I guess, in my case the information is mostly in the linked ticket.
- If you accidentaly press enter and need to amend, you don't need to write the message again, just edit the part you want in the editor.
- My terminal do not have render issues.
- For the pre-commit hook it's been a while since I used one on commit messages, but how does it check the message validity before commiting using a terminal editor ?
TL;DR: the only point I found applicable in my case is the argument on special characters (such as $), but it never happened to me for now