Skip to main content

Branch Commit messages

Commit messages might seem like an afterthought in a developer’s workflow — but they’re actually one of the most powerful tools for maintaining a healthy codebase and ensuring effective team collaboration. At their core, commit messages tell the story of how a project evolves over time, capturing the what, why, and how of each change. When done well, they help newcomers get up to speed quickly, make bug-hunting far less painful, and provide clarity about decisions that might otherwise get lost. In other words, a solid commit message is an investment in your project’s longevity and your team’s sanity.

Use an Imperative, Descriptive Subject Line

  • Imperative Mood: Write as if you’re giving a command, e.g., “Fix bug in login form” instead of “Fixed bug…” or “Fixes bug…”.
  • 50-Character Limit: Keep the subject line under ~50 characters if possible.
  • Example: Add user authentication middleware

Separate Subject from Body with a Blank Line (for Advanced Projects)

  • Why? Many tools (like git log --oneline) show only the first line, so it’s good to have a concise summary.
  • Then hit “Enter” twice (blank line) to start your more detailed body.

Write a Detailed Body (When Needed, for advanced Projects)

  • Explain What & Why: Provide context on what changed and why it was needed.
  • Wrap Lines at ~72 Characters: This ensures readability in various git tools.
  • Example:
Add user authentication middleware

- Implement new middleware to handle JWT-based authentication.
- Remove session-based logic in the old auth controller.
- Update tests accordingly.

Closes #123

Keep Commits Small & Focused

  • Each commit should ideally contain changes for one logical task or fix.
  • Don’t lump unrelated changes together. If you’re fixing a bug and refactoring code, consider two separate commits.

Provide Meaningful Merge Commit Messages

  • When merging branches, don’t just leave merge dev or merged master.
  • Add context, e.g., Merge feature/payment-processing into develop plus a short summary of the changes.

Extra Tip

Many teams use a tool called Husky that intercepts Git commits and checks the commit message using JavaScript. The commit is only allowed if the message follows the defined conventions.

warning

Husky has not been tested yet.