How to Write a Git Commit Message?
Fleeting- Référence externe : https://chris.beams.io/posts/git-commit/
How to Write a Git Commit Message
Commit messages matter
best way to communicate context about a change to fellow developers
, a commit message shows whether a developer is a good collaborator
There is a vicious cycle here: because the commit history is unstructured and inconsistent, one doesn’t spend much time using or taking care of it. And because it doesn’t get used or taken care of, it remains unstructured and inconsistent
Understanding why something happened months or years ago becomes not only possible but efficient
In order to create a useful revision history, teams should first agree on a commit message convention that defines at least the following three things:
Style. Markup syntax, wrap margins, grammar, capitalization, punctuation. Spell these things out, remove the guesswork, and make it all as simple as possible. The end result will be a remarkably consistent log that’s not only a pleasure to read but that actually does get read on a regular basis.Content. What kind of information should the body of the commit message (if any) contain? What should it not contain?Metadata. How should issue tracking IDs, pull request numbers, etc. be referenced?
The seven rules of a great Git commit messageKeep in mind: This has all been said before.Separate subject from body with a blank lineLimit the subject line to 50 charactersCapitalize the subject lineDo not end the subject line with a periodUse the imperative mood in the subject lineWrap the body at 72 charactersUse the body to explain what and why vs. how
not every commit requires both a subject and a body
when a commit merits a bit of explanation and context, you need to write a body
There are a number of other contexts in Git where the distinction between subject line and body kicks in—but none of them work properly without the blank line in between.2. Limit
50 characters is not a hard limit, just a rule of thumb
So shoot for 50 characters, but consider 72 the hard limit.3.
A properly formed Git commit subject line should always be able to complete the following sentence:If applied, this commit will your subject line here
Remember: Use of the imperative is important only in the subject line. You can relax this restriction when you’re writing the body.6. Wrap the bo
Use the body to explain what and why vs. how