Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cowardly refusing to install hooks with `core.hooksPath` set

I tried to run this command but it always shows this error. Help me, please!

$ pre-commit install
[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.
hint: `git config --unset-all core.hooksPath`
like image 870
Hữu Tuân Avatar asked Dec 07 '25 09:12

Hữu Tuân


2 Answers

  1. Run:

    git config --unset-all core.hooksPath
    
  2. If the global core.hooksPath is not empty, run:

    git config --global --unset-all core.hooksPath
    

    But of course, it's global so be careful.

    Why pre-commit is nonfunctional with global hooks? see issue

like image 160
Noam Nol Avatar answered Dec 09 '25 21:12

Noam Nol


You are getting the above error because of setting up a global hook path.

It can be resolved in below two ways: -

  1. Unset the global hook path as below: -

    git config --unset core.hooksPath
    
  2. Set local hooks path as below: -

    git config --local core.hooksPath .git/hooks
    

There is a very interesting conversation on this topic, I will highly recommend going through it once:-

issue Cowardly refusing to install hooks with core.hooksPath set

Please let me know in the comments if this resolves your problem. I am super curious about it.

like image 31
Pratap Alok Raj Avatar answered Dec 09 '25 23:12

Pratap Alok Raj