This guide will help you activate local automatic validation of commit messages using the Conventional Commits format. It is intended for those who will clone repositories that are already set up with Git hooks, the pre-commit framework, and the git-conventional-commits package.
- Check for pre-commit Installation
After cloning the repository, check if pre-commit is installed on your machine by running the following command:
> pre-commit --versionIf you get an error, you’ll need to install pre-commit first. You can do this by running (requires both python and pip):
> pip install pre-commitOnce installed, verify by running the same command again:
> pre-commit --version- Install Git Hook
Next, navigate to the root directory of your cloned repository and run the following command to install the commit-msg hook:
> pre-commit install -t commit-msgYou're Done!
Now you're all set! The pre-commit hook will automatically validate your commit messages to ensure they follow the Conventional Commits format. Try making some changes (e.g., adding a new feature 😎 or fixing a bug 😨), stage them, and then commit. The hook will check your commit message, and if it doesn't follow the proper convention, it will reject the commit.
Her you can see an example for a successful validation:
And here for a unsuccessful one:
Have fun :)

