10

If husky hook is not running, we need to execute command chmod +x .husky/*. But I need to run chmod +x .husky/* every time I go to a new branch. Otherwise, it shows this error:

hint: The '.husky/pre-commit' hook was ignored because it's not set as executable.

Can anybody tell me how can I solve this issue?

I am using husky 7.0.1

Arif
  • 6,094
  • 4
  • 49
  • 81

2 Answers2

20

I got my solution. I added pre-commit file manually so it was not executable(644). I removed pre-commit file and added using this command yarn husky add .husky/pre-commit that makes pre-commit file executable(755) and works fine any new branch.

So, to solve this type of issue, we have to avoid adding manual hook file and use this command yarn husky add .husky/<hookname> to add.

Arif
  • 6,094
  • 4
  • 49
  • 81
14

You can also add "prepare": "husky install && chmod ug+x .husky/*" to your scripts in package.json to automatically set executable permissions while enabling Git hooks.

Ivan
  • 151
  • 2