A professional Git commit should be clear, concise, and meaningful so that anyone reviewing the history can understand what changes were made and why. Follow these best practices:
A commonly used format is:
<type>(<scope>): <short description>
[Optional longer description explaining what and why]
[Optional references to issues or PRs]
feat, fix, chore, docs, refactor, test, style)Fixes #123)For a new feature:
feat(auth): add JWT authentication middleware
Implemented JWT-based authentication middleware for secure API access.
Users must provide a valid token to access protected routes.
For a bug fix:
fix(profile): resolve issue with avatar not updating
Fixed a bug where the user’s profile avatar wouldn’t update after upload.
The cache was not clearing properly, which caused old images to persist.
For refactoring code:
refactor(db): optimize user query performance
Replaced multiple redundant queries with a single optimized SQL query.
Improves API response time by 30%.