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

i tried to run this command but it always show this error, i can't fix it with anyway. Help me, please!

(venv)<...>pre-commit install

[ERROR] Cowardly refusing to install hooks with core.hooksPath set.

hint: git config --unset-all core.hooksPath



Solution 1:[1]

  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

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Alok Raj