Home·Error messages

husky · Git

The message

husky - pre-commit hook exited with code 1 (error)

What it means

Your commit was never created: a hook — lint, tests, a formatter — exited non-zero and git aborted. The real reason is not this line but the hook's own output above it, usually a lint rule or a type error. Fixing what the hook reported and committing again is the only real answer. git commit --no-verify skips every commit hook and does produce a commit, but it has not passed the check, it has only moved the failure to CI, and unformatted code goes straight to your colleagues.

The fix

git commit --no-verify
Printed by
husky
Git
29

Almost every git error is a refusal that means "doing that from this state would lose something"; fatal: means git stopped without changing anything, and the hint: lines under the first line usually carry the actual remedy.

Reading an error message

  • Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
  • If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
  • Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
  • The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
  • Before pasting a fix, check what it throws away. Some of these cannot be undone.

Common questions

Q. What does “husky - pre-commit hook exited with code 1 (error)” mean?

Your commit was never created: a hook — lint, tests, a formatter — exited non-zero and git aborted. The real reason is not this line but the hook's own output above it, usually a lint rule or a type error. Fixing what the hook reported and committing again is the only real answer. git commit --no-verify skips every commit hook and does produce a commit, but it has not passed the check, it has only moved the failure to CI, and unformatted code goes straight to your colleagues.

Q. How do I fix it?

git commit --no-verify — before running it, check the explanation above for what this command discards.

Q. Which tool prints this?

husky. It sits under Git, and the message runs to 9 words.

Errors nearby