Skip to content

Conventional Commits

Write commit messages that are clear, consistent, and helpful for your team.

type: description
# Example:
feat: add user login button
fix: resolve header styling issue
docs: update setup instructions
  • 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.

Add scope in parentheses for more context:

Terminal window
# Component-specific changes
git commit -m "feat(auth): add password reset flow"
git commit -m "fix(header): resolve mobile menu bug"
# Feature-specific changes
git commit -m "feat(dashboard): add user statistics"
git commit -m "fix(payment): handle failed transactions"
# File-specific changes
git 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 authentication
git 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"
Terminal window
# Fixing issues found in testing
git 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"
Terminal window
# Updating project docs
git commit -m "docs: add component usage examples"
git commit -m "docs(api): document authentication endpoints"
git commit -m "docs: update contributing guidelines"

For major changes that break existing functionality:

Terminal window
# Add exclamation mark
git commit -m "feat!: change API response format"
git commit -m "refactor!: update user data structure"
# Or use BREAKING CHANGE in body
git commit -m "feat: update user authentication
BREAKING CHANGE: Login endpoint now requires email instead of username"

For more complex changes:

Terminal window
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"

Connect commits to GitHub issues:

Terminal window
# Reference issue
git commit -m "fix(auth): resolve login timeout issue
Fixes #45"
# Multiple issues
git commit -m "feat(dashboard): add user statistics
Implements #67, #68, #69"
# Close issue
git commit -m "feat(api): add user search endpoint
Closes #91"
  • Clear: Easy to understand what changed
  • Specific: Focused on one change
  • Consistent: Follows the same format
  • Helpful: Useful for reviewing history

Good:

Terminal window
feat(auth): add password reset functionality
fix(ui): resolve header overlap on mobile
docs(api): add authentication examples

Bad:

Terminal window
stuff
fixed things
wip
update
  • 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
  • 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!

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.

  1. Stage Your Changes: Add the files you want to commit to the staging area
  2. Open Source Control: Navigate to the Source Control panel in VS Code
  3. Generate Message: Click the sparkle icon (✨) next to the commit message box
  4. Review & Commit: VS Code will analyze your changes and suggest a conventional commit message

VS Code commit message generation interface

The AI will create properly formatted conventional commits based on your actual code changes:

Example of AI-generated conventional commit message

  • 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!