4 ms·
The most important tip is "Use the body to explain what and why vs. how". I'd also say: remove thw -m option from git and force people to open the editor. Do n
by pmontra 10y ago
The most important tip is "Use the body to explain what and why vs. how".
I'd also say: remove thw -m option from git and force people to open the editor. Do not accept messages shorter than 3 lines, start the editor with a template
Title
What changed and why it changed.
- dtech 10y agoYou can easily enforce this if you want through a pre-commit hook, but this is frankly ridiculous to enforce on everybody.
- ecma 10y agoIt's likely that this would push the tools toward being too opinionated. I spend a lot of time pushing little WIPs so I know where I am and my macros rely heavily on -m, e.g. I end up with a commit message like "WIP: don't merge these debugging lines" or "WIP: Tweak the IO timeout and profile". -m is also useful for making trivial commits, I don't use it for this often because it's easy to violate 50 chars but it's a perfectly valid use of the tool IMO.
- eriknstr 10y agoFor my own commits in my personal repos I often find that less than 80 chars are sufficient to describe the change entirely. I generally don't care about surpassing 80 chars for commit messages though, so even if my commit message is somewhat long I won't split it up. I commit very often and usually small, "atomic" changes most of the time. What I will do, is that I start the commit message with the most important sentence and add less important sentences after, so even if it exceeds 80 chars and you can't see the whole message you will still get the most relevant info without having to scroll sideways. For reference, here are the commits to a project I am currently working on: https://github.com/eriknstr/jumper/commits/master https://github.com/eriknstr/jumper/commits/master
- rosser 10y agoDogmatism like "commit messages must be at least three lines" will result in commit messages like: here's some code. Concentrating on form over substance is myopic.
- petepete 10y agoTotally agree. Using three lines of text to describe fixing a typo in the comments or rewording/reformatting a block of text will just lead to an unclear message.
- tomjen3 10y agoFrom SO: >Git can take the commit message from a file using the -F or --file flags: >git commit -F message.txt So something like echo 'pmontra\n say\n this\n should be several lines' | git commit -F /dev/stdin would get around your block.
- jwilk 10y agoYou want printf, not echo. echo is a very non-portable command. POSIX says: "if any of the operands contain a <backslash> character, the results are implementation‐defined."