I get the feeling almost everybody uses an editor (Vim, Notepad++, etc.) for the Git commit messages. Why?
I find typing -m
and a couple of quotes is easy and provides a easy way to redo a commit (pressing up arrow). I guess it's easier to do multi-line commit messages in an editor, but I have a hard enough time convincing fellow co-workers to write any message!
Well-crafted commit messages are the best way to communicate why the commit was necessary, giving some context to the code changes. Commit messages are also very handy when looking over recent changes to the code base. Commit messages can give you a quick idea of what has changed recently.
You can change the most recent commit message using the git commit --amend command. In Git, the text of the commit message is part of the commit. Changing the commit message will change the commit ID--i.e., the SHA1 checksum that names the commit. Effectively, you are creating a new commit that replaces the old one.
You mentioned the most important thing - length. Commit messages should essentially always be multi-line. The only exceptions are trivial commits (e.g. "bumped version number to X.X.X") or merges with no conflicts (though even then, appending a shortlog isn't a bad idea). The average commit, as far as such a thing exists, should probably have a sentence or two beyond the subject; some could even have paragraphs. Just look at the log of git.git; it's pretty much guaranteed to be a good example of commit message style and length.
I realize that it may be hard to convince others to write good commit messages, but that doesn't mean you can't - and you will probably find it easier to use an editor to write them.
(I have exactly the same experience in my workplace. My coworkers are engineers first, programmers second, and version control users... third would be generous. But you can at least do your job right!)
A proper git commit message should almost always be multi-line. From the official git-commit discussion,
Though not required, it's a good idea to begin the commit message with a single short (less than 50 character) line summarizing the change, followed by a blank line and then a more thorough description. Tools that turn commits into email, for example, use the first line on the Subject: line and the rest of the commit in the body.
If you're having a hard time getting any commit messages, (talk to your sysadmin and/or) make sure that at least one of the GIT_EDITOR environment variable, the core.editor configuration variable, the VISUAL environment variable, or the EDITOR environment variable is set to something useful.
An option would be to create your own 'editor', which prompts for a short (<50 chars) description, and then a minimum number of characters or sentences. This might not be well received, but that would depend on your position and the culture of your work environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With