Webstorm, Husky and Commitizen

Note: this article is valid only for Husky <= 4

Husky 7 has changed the way they interface with Git

Our team is using Commitizen to enforce format of git commit messages (this is later used to auto-generate changelogs and bump version). And we’re using Husky to make sure everyone joining the team has commitizen running as a git hook.

Now, I am using Webstorm and I create my commit directly from my IDE.  The commitizen git hook prepare-commit-msg clashes with Webstorm because it is meant to be used in a CLI environment.

The solution I am using is

  • Use Git Commit Template plugin for Webstorm to format git messages
  • After a fresh `​npm install` (husky recreates its git hook), I have to
    • Manually edit `.git/hooks/prepare-commit-msg`
    • To comment the line that runs husky by simply adding a # at the beginning of the line
      `. “$(dirname “$0”)/husky.sh”`

Of course, Webstorm is configured to “Run git hooks”. So it will keep running the others hooks we have (lint, tests, …). But it will skip the prepare-commit-msg hook.

Leave a comment