54

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?

torek
  • 448,244
  • 59
  • 642
  • 775
Ben Alan
  • 1,399
  • 1
  • 11
  • 27
  • 7
    What it means is that you've added a non-Git program (specifically, something called "husky") and told Git to *use* Husky to check your commits. Husky did so, Husky found errors, Husky reported those errors, and Git obeyed Husky's result, preventing the commit. Your question is thus entirely about Husky, not Git. – torek Jul 05 '21 at 20:27
  • 2
    Thank you for the correction. Never heard of husky before :) – Ben Alan Jul 05 '21 at 20:32

6 Answers6

72

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 !

Pierre Carbonnelle
  • 2,305
  • 19
  • 25
  • 1
    Many OSS projects require conventional commit message, it's part of the build and release process and a bunch of that automation relies on the commit messages to perform it's job correctly. – Chris Oct 15 '21 at 20:47
  • @BenAlan With a commit convention, packages can be updated automatically and released with their version in the correct stands of SemVer, take a look at this article (it's not mine) https://platform.deloitte.com.au/articles/semantic-versioning-with-conventional-commits – Leandro Lima Mar 23 '22 at 22:49
26

Another Solution you can try is

git commit --no-verify -m "Hello World!"

git commit -n -m "Hello World!"

References

  1. Git hooks (https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks)
  2. check for conventional commit.
  3. What is commit lint and setting up?
Ashish Singh Rawat
  • 1,419
  • 16
  • 30
22

For me it was a space. Changed

`feat(pill):message here` 

to

`feat(pill): message here`

There is a package called husky that defines a certain template for your commit messages. If the template is not fulfilled, one gets strange errors.

GoTo
  • 5,966
  • 2
  • 28
  • 31
16

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.

Ben Alan
  • 1,399
  • 1
  • 11
  • 27
  • 8
    You should not unninstall packages if you don't know what it does, in that case, husky grants a convention for commits, pls take a time to read about https://www.conventionalcommits.org/en/v1.0.0/ And https://typicode.github.io/husky/#/ – Leandro Lima Mar 23 '22 at 22:51
  • This is the most correct answer since you didn’t know what the hooks were doing, or wanted. Git hooks are designed to be installed per repository, not project-wide (security concerns). Dunno how you ended up with Husky, though. – Guildenstern May 16 '23 at 20:58
0

As you installed husky it checks when you commit or push the code in to your github repo. I guess you have installed the commitlint and used it in your .husky precommit file . If so you have to follow the commitlint rules before every commit like "fix: bug-fixes" .

refer:https://commitlint.js.org/#/

0
$ git commit -m "feat: hello-world-somthing-else"
Rich
  • 6,470
  • 15
  • 32
  • 53
Mr.Sharp
  • 41
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 22 '23 at 20:09
  • I'm not sure how this could be helpful. It appears to be the exact same syntax as in the question. – Rich May 24 '23 at 15:12