We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. But also, we use the git commit messages to generate the Change Log.
Example:
Fix[consultation]: Add hat wobble
^--^^------------^ ^------------^
| | |
| | +--> Description in present tense and Capitalised.
| |
| +---------------> Scope (Optional, lowercase)
|
+-------------------> Type: Feat, Fix, Chore, Docs, Revert, Refactor, Style, or Test. (Capitalised)
- Feat: A new feature
- Fix: A bug fix
- Chore: Other changes that don't modify src or test files
- Docs: Documentation only changes
- Refactor: A code change that neither fixes a bug nor adds a feature
- Style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- Test: Adding missing tests or correcting existing tests
If the commit reverts a previous commit, it should begin with revert:
, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>
., where the hash is the SHA of the commit being reverted.
The scope could be anything specifying place of the commit change. For example: consultations, person/medical-history, etc.
“Atomic commit” is basically a fancy way of saying a commit that commits one and only one thing. It’s a single complete unit of work.
https://www.codewithjason.com/atomic-commits-testing/
The commit summary contains succinct description of the change:
- Use the imperative, present tense: "Change" not "Changed" nor "Changes".
- Capitalize first letter
- no dot (.) at the end
--
Commit messages are important means of communication between team members and for the lifecycle of the team: its past and its future.
What makes a good commit message?
The seven rules of a great Git commit message:
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how