Conventional Commits
Write commit messages that are clear, consistent, and helpful for your team.
Basic Format
Section titled “Basic Format”type: description
# Example:feat: add user login buttonfix: resolve header styling issuedocs: update setup instructions
Common Types
Section titled “Common Types”Main Types:
Section titled “Main Types:”- feat: New feature or functionality
- fix: Bug fix
- docs: Documentation changes
- style: Code formatting (no logic changes)
- refactor: Code improvement (no new features)
- test: Adding or updating tests
- chore: Build tasks, dependencies, etc.
With Scope (Optional)
Section titled “With Scope (Optional)”Add scope in parentheses for more context:
# Component-specific changesgit commit -m "feat(auth): add password reset flow"git commit -m "fix(header): resolve mobile menu bug"
# Feature-specific changesgit commit -m "feat(dashboard): add user statistics"git commit -m "fix(payment): handle failed transactions"
# File-specific changesgit commit -m "docs(readme): add installation guide"git commit -m "test(api): add user endpoint tests"```f
## Real Examples from Our Workflow
### Feature Development:```bash# Working on user authenticationgit commit -m "feat(auth): add login form component"git commit -m "feat(auth): implement JWT token handling"git commit -m "feat(auth): add logout functionality"
Bug Fixes:
Section titled “Bug Fixes:”# Fixing issues found in testinggit commit -m "fix(ui): resolve button spacing issue"git commit -m "fix(api): handle empty response error"git commit -m "fix(mobile): fix responsive layout"
Documentation:
Section titled “Documentation:”# Updating project docsgit commit -m "docs: add component usage examples"git commit -m "docs(api): document authentication endpoints"git commit -m "docs: update contributing guidelines"
Breaking Changes
Section titled “Breaking Changes”For major changes that break existing functionality:
# Add exclamation markgit commit -m "feat!: change API response format"git commit -m "refactor!: update user data structure"
# Or use BREAKING CHANGE in bodygit commit -m "feat: update user authentication
BREAKING CHANGE: Login endpoint now requires email instead of username"
Multi-line Commits
Section titled “Multi-line Commits”For more complex changes:
git commit -m "feat(payment): add Stripe integration
- Add Stripe SDK configuration- Implement payment form component- Add error handling for failed payments- Update user dashboard to show payment status
Closes #123"
Linking to Issues
Section titled “Linking to Issues”Connect commits to GitHub issues:
# Reference issuegit commit -m "fix(auth): resolve login timeout issue
Fixes #45"
# Multiple issuesgit commit -m "feat(dashboard): add user statistics
Implements #67, #68, #69"
# Close issuegit commit -m "feat(api): add user search endpoint
Closes #91"
Quick Reference
Section titled “Quick Reference”What Makes a Good Commit:
Section titled “What Makes a Good Commit:”- Clear: Easy to understand what changed
- Specific: Focused on one change
- Consistent: Follows the same format
- Helpful: Useful for reviewing history
Examples of Good vs Bad:
Section titled “Examples of Good vs Bad:”Good:
feat(auth): add password reset functionalityfix(ui): resolve header overlap on mobiledocs(api): add authentication examples
Bad:
stufffixed thingswipupdate
Team Benefits
Section titled “Team Benefits”Why This Helps:
Section titled “Why This Helps:”- Code Reviews: Reviewers understand changes quickly
- Release Notes: Automatically generate from commit types
- Bug Tracking: Easy to find when bugs were introduced
- History: Clean, readable project history
Tools Integration:
Section titled “Tools Integration:”- GitHub: Automatically links commits to issues
- Release Tools: Generate changelogs from commit types
- CI/CD: Trigger different actions based on commit type
Keep it simple and be consistent! Your future self (and teammates) will thank you!
AI-Powered Commit Message Generation
Section titled “AI-Powered Commit Message Generation”VS Code can automatically generate conventional commit messages for your changes using GitHub Copilot (requires a paid GitHub plan). This feature analyzes your staged changes and suggests appropriate commit messages that follow conventional commit standards.
How to Use:
Section titled “How to Use:”- Stage Your Changes: Add the files you want to commit to the staging area
- Open Source Control: Navigate to the Source Control panel in VS Code
- Generate Message: Click the sparkle icon (✨) next to the commit message box
- Review & Commit: VS Code will analyze your changes and suggest a conventional commit message
Generated Result:
Section titled “Generated Result:”The AI will create properly formatted conventional commits based on your actual code changes:
When This Feature is Most Helpful:
Section titled “When This Feature is Most Helpful:”- Large Changes: When you have multiple files with different types of changes
- Complex Refactoring: AI can identify the main purpose of your refactoring
- Learning: Great for teams new to conventional commits
- Consistency: Ensures all team members follow the same format
Remember: Always review the generated message to ensure it accurately describes your changes!