Commit Conventions
Why?
A clean commit history gives us the ability to find changes swiftly when it's most needed, on top of that it allows us to do run automations.
The conventions
We'll take this commit message along with us to explore the conventions in this document.
$ git commit -m "Add a new colleague to the Libaro team T12345"Verbs
$ git commit -m ">> Add << a new colleague to the Libaro team T12345"Every commit message MUST starts with one of the verbs listed below. The verb MUST start with an uppercase letter. These verbs show us the nature of the changes made in the commit. A good rule of thumb is that you should be able to prefix your commit message with "This commit will ..."
| Verb | Used for |
|---|---|
| Add | Adding new files, directories, methods, ... |
| Doc | Adding or updating documentation (Indeed, not a verb. Sue me!) |
| Fix | Fixing bugs |
| Move | Moving files or directories |
| Refactor | Optimizing queries, cleaning up code, general refactors... |
| Remove | Removing files, directories, methods, ... |
| Revert | Reverting changes |
| Update | Updating logos, updating content |
| Upgrade | Upgrading a version of a dependency |
| Downgrade | Downgrading a version of a dependency |
| WIP | Again, not a verb, but we allow this one for code that is not yet finished but needs an intermediate save. E.g. to stash changes remotely when switching branches |
Description
$ git commit -m "Add >> a new colleague to the Libaro team << T12345"After the verb comes a succinct ¹ description that clearly conveys what the change will do while leaving out filler words like though, maybe, I think, kind of, etc...
- Succinct - /səkˈsɪŋ(k)t/ - (especially of something written or spoken) briefly and clearly expressed.
Ticket number
$ git commit -m "Add a new colleague to the Libaro team >> T12345 <<"The ticket number MUST be added to the commit that finalizes the feature you're working on. This is used in to link commits to tickets in forecast (our planning tool).
But what if I need to add some last minute changes and already pushed a commit with the ticket number?
Just add the ticket number to the new last commit as well.