I type this into the CLI
git commit -m "Hello World!"
This is the error message I get
husky > commit-msg (node v14.15.3)
⧗ input: Hello World!
✖ subject may not be empty [subject-empty]
✖ type may not be empty [type-empty]
✖ found 2 problems, 0 warnings
ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint
husky > commit-msg hook failed (add --no-verify to bypass)
What does this mean?
Pushing an empty commit without adding any staged files to the branch is very easy. It is the same as pushing a regular commit, except that all you need to do is add –allow-empty flag to the command line. The commit is now pushed to your branch without any changes.
Creating an empty commit is easy. You simply add the --allow-empty flag on git commit command and add your message. Now you can create all the empty commits you want!
Git commit messages are necessary to look back and see the changes made during a particular commit. If everyone will just commit without any message, no one would ever know what changes a developer has done.
Commitlint is a simple tool that lints your commit messages and makes sure they follow a set of rules. It runs as a husky pre-commit hook, that is, it runs before the code is committed and blocks the commit in case it fails the lint checks.
To fix the error, change your commit message ("Hello world") to follow the Conventional Commits format, e.g. to "feat: hello world".
As the "Get Help" message link (in your error message) explains, husky calls commitlint to verify that your commit message conforms to this format.
We should always RTFEM !
I fixed this problem with "npm uninstall husky"
edit: make sure you know what it does and that your project doesn't use it before you remove it.
Another Solution you can try is
git commit --no-verify -m "Hello World!"
git commit -n -m "Hello World!"
References
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With