Writing clear and professional Git commits is more than a habit—it’s a skill that makes collaboration smoother, code history readable, and debugging easier. Here’s a concise guide to crafting quality commits.
🔹 Structure of a Good Commit
A professional commit usually consists of:
1) Type – what kind of change it is (feature, fix, docs, etc.)
2) Short message – 50 characters max, written in imperative tone (e.g., “Add login validation”)
3) Optional detailed description – wrap text at 72 characters for readability, explaining why the change was made
🔹 Common Commit Types
feat: Adding a new feature
fix: Bug fix
docs: Documentation-only changes
style: Formatting, missing semicolons, whitespace
refactor: Code change that neither fixes a bug nor adds a feature
test: Adding or updating tests
chore: Maintenance tasks (configs, dependencies)
🔹 Good commits
feat: add user authentication
fix: resolve crash on profile update
docs: update README with installation steps
style: format code with Prettier
refactor: simplify dashboard component logic
test: add unit tests for login reducer
chore: update project dependencies
🔹 Pro Tips
1) Always use imperative mood: e.g., Add feature instead of Added feature
2) Keep your commits focused: one commit = one purpose
3) Include context in the description when necessary
Top comments (0)