How to Write Good Commit Messages in Git
As the creator of CoreUI and with over 25 years of software development experience, I’ll show you how to write effective commit messages that improve project maintainability and team collaboration.
Good commit messages should be concise, descriptive, and follow a consistent format with a clear subject line and optional detailed body explaining the why behind changes.
# Good commit message structure
git commit -m "feat: add user authentication with JWT tokens
- Implement login and registration endpoints
- Add JWT token generation and validation
- Include password hashing with bcrypt
- Add middleware for protected routes
Closes #123"
# More examples of good commit messages
git commit -m "fix: resolve memory leak in data table component"
git commit -m "docs: update API documentation for v2.0 endpoints"
git commit -m "refactor: extract common validation logic into utils"
git commit -m "style: format code according to ESLint rules"
git commit -m "test: add unit tests for user service functions"
git commit -m "chore: update dependencies to latest versions"
# Use conventional commit format
git commit -m "type(scope): description
Optional body explaining what and why
Footer with issue references"
Follow the conventional commit format: type(scope): description. Common types include feat (new feature), fix (bug fix), docs (documentation), style (formatting), refactor (code restructuring), test (adding tests), and chore (maintenance). Keep the subject line under 50 characters, use imperative mood (“add” not “added”), capitalize the first letter, and don’t end with a period. Use the body to explain what and why, not how.
Best Practice Note:
In CoreUI projects, we use conventional commits extensively to automate changelog generation and semantic versioning. Clear commit messages help our team understand changes quickly and make debugging much easier when tracking down issues in complex UI components.



