DEV Community

Tomas Stveracek
Tomas Stveracek

Posted on

Write Commits Like a Pro: 5 Key Rules + 25 Bonus Verbs

Writing good commit messages is crucial for maintaining a clear and understandable project history. Proper commit messages help other developers understand the context and reasoning behind changes, making collaboration easier and more efficient. Here are 5 rules for writing better commit messages, along with examples of good and bad commit messages.

1. Write in English, because you often work in international teams

❌ Bad: Text in your language

✅ Good: Fix user login issue

2. Start with a verb in the imperative mood

❌ Bad: Fixing user login issue

✅ Good: Fix user login issue

3. Be concise

❌ Bad: This commit addresses an issue with the user login functionality where users were unable to log in due to an error in the authentication module.

✅ Good: Fix error in user authentication

4. Be specific, not vague like "change function"

❌ Bad: Change function

✅ Good: Update function to handle edge cases in user input

5. Provide context to show what changes affect

❌ Bad: Optimize code

✅ Good: Optimize data processing function

Bonus: 25 Verbs for Better Commits

Don’t just use "Fix". Use these verbs to improve the quality of your commit messages:

  1. Update
  2. Modify
  3. Amend
  4. Enhance
  5. Adjust
  6. Refine
  7. Tweak
  8. Polish
  9. Upgrade
  10. Refactor
  11. Optimize
  12. Patch
  13. Improve
  14. Fix
  15. Add
  16. Remove
  17. Implement
  18. Clean
  19. Restructure
  20. Streamline
  21. Correct
  22. Expand
  23. Simplify
  24. Secure
  25. Document

These verbs can help make your commit messages more descriptive and meaningful, providing clearer context for your changes.

Conclusion

Writing good commit messages is an important skill for any developer. Clear, concise, and descriptive commit messages make it easier to understand and collaborate on a project. By following these rules and learning from good and bad examples, you can improve the quality of your commit messages and contribute to a more maintainable and understandable codebase.

Top comments (0)