Writing good Git commit messages matters!

A thread about how to write clean commit messages:

🧵 👇
1️⃣ Make your commit messages meaningful, explaining the reason for the change. The more explicit the message is, the more helpful it will be.

Examples:

❌Don't:
- fixed
- done
- added 2 class

✅Do:
- add missing validation to login form
- fix bug for calculating cart price
2️⃣ Use the imperative mood

Imperative mood means that the commit message should be written as if giving a command or instruction.

Examples:

❌Don't:
- I have implemented ...
- this commit will ...
- more fixes for broken stuff

✅Do:
- add ...
- fix ...
- remove ...
3️⃣ Use present tense

Git commits can be checked out, merged, reverted or cherry-picked.

A properly formed Git commit line should be able to complete the following sentence:

- If applied, this commit will...

In order to complete this sentence, using present tense is needed.
4️⃣ Add link reference to the actual user story, task or bug

If you use project management tools such as Jira, GitLab or Azure DevOps then you can add the reference-id to the actual working item.

Template:
#<item-id>:<message>

Example:
#d342da: Fix bug on client validation
5️⃣ Commit length:

Most of the time if you have long commit messages it means that you violate the following principle:

- Commit early & commit often

If you take baby steps and commit your work frequently, then you won't have issues with the commit length.
✅ Tips for writing clean commit messages (sum up):

- make your commit messages meaningful, explaining the reason for the change
- use the imperative mood
- use present tense
- add link reference to the actual user story, task or bug
- commit early & commit often

Enjoy! 🙏❤️
You can follow @dmokafa.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled:

By continuing to use the site, you are consenting to the use of cookies as explained in our Cookie Policy to improve your experience.