The Anatomy of a Conventional Commit
A conventional commit consists of a type, an optional scope, and a concise summary message: `type(scope): description`.
`feat:` communicates a new feature that automatically triggers a MINOR semver release. `fix:` communicates a bug patch triggering a PATCH semver release. Appending an exclamation mark (`feat!:`) or adding a `BREAKING CHANGE:` footer triggers a MAJOR release.
Enforcing Commit Standards with Git Hooks
Developers frequently forget formatting conventions when in a rush. By integrating Husky and @commitlint/cli into your repository, invalid commit messages are blocked locally on git commit with instant remediation feedback.
In CI/CD pipelines (GitHub Actions), tools like semantic-release read these standardized commits and automatically publish GitHub releases and npm packages.
Step-by-Step Tutorial
Install Commitlint and Husky
Run `npm install -D @commitlint/config-conventional @commitlint/cli husky` in your project root.
Create commitlint.config.js
Add `module.exports = { extends: ["@commitlint/config-conventional"] };` to enforce standard prefix types.
Set Up Git commit-msg Hook
Run `npx husky init` and add `npx --no -- commitlint --edit $1` into `.husky/commit-msg`.
Ready to Try It Yourself?
DocSwift processes everything directly on your device. Fast, safe, and completely free forever.
How helpful was this guide?
Rated 4.9 / 5 by 3,420+ users worldwide
Share with Colleagues & Friends
Help others protect their document privacy
Frequently Asked Questions
What happens if I make an error in a commit message?
If you have not pushed to remote yet, fix it immediately using `git commit --amend -m "feat: corrected message"`. If you pushed to a feature branch, amend and force push safely with `--force-with-lease`.
Does Conventional Commits work with Squash & Merge on GitHub?
Yes! In fact, Squash & Merge is the easiest way to adopt it. Team members can commit freely on their feature branch, and the pull request title is formatted as the Conventional Commit upon merge.