A conventional commit message follows this structure:
<type>[optional scope]: <description> [optional body] [optional footer(s)] The type describes the kind of change being made. Common types include:
The scope provides additional context about what part of the codebase is affected:
feat(auth): add OAuth2 integration fix(api): resolve timeout issues docs(readme): update installation instructions A brief description of the change:
Provides more detailed explanation of the change:
Contains metadata about the commit:
BREAKING CHANGE:Closes #123, Fixes #456Co-authored-by: Name <email>feat: add user authentication fix(parser): handle edge case in JSON parsing feat: add email notifications Users can now receive email notifications for important events. This includes account changes, security alerts, and system updates. fix: prevent racing of requests Introduce a request id and a reference to latest request. Dismiss incoming responses other than from latest request. Closes #123 feat!: send an email to the customer when a product is shipped BREAKING CHANGE: The shipping service now requires an email address feat(shopping cart): add ability to remove items Users can now remove items from their shopping cart by clicking the remove button next to each item. This improves the user experience by allowing corrections without starting over. Closes #456 Co-authored-by: Jane Doe <jane@example.com> Interactive tool for creating conventional commits:
npm install -g commitizen npm install -g cz-conventional-changelog echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc Usage:
git cz Lints commit messages to ensure they follow conventional format:
npm install --save-dev @commitlint/config-conventional @commitlint/cli Configuration in .commitlintrc.json:
{ "extends": ["@commitlint/config-conventional"] } Git hooks to enforce commit message format:
npm install --save-dev husky npx husky add .husky/commit-msg 'npx --no -- commitlint --edit ${1}' Automatically generates releases based on conventional commits:
npm install --save-dev semantic-release Generates changelogs from conventional commits:
npm install -g conventional-changelog-cli conventional-changelog -p angular -i CHANGELOG.md -s