I have a git repository with a pre-commit hook set up :
my-repo
|- .git
|- hooks
|- pre-commit # I made this file executable
Until there, everything works. The hook is running when I commit.
=================================
I now run git config core.hooksPath ./git-config/hooks
in my-repo
.
The folder structure is this one :
my-repo
|- .git
|- hooks
|- git-config
|- hooks
|- pre-commit # I made this file executable as well
What happens is :
my-repo/.git/hooks
git config --get core.hooksPath
in my-repo
outputs ./git-config/hooks
How can I make the new pre-commit hook run on commit ?
Here's the link to the docs I apparently don't understand well :
https://git-scm.com/docs/git-config
https://git-scm.com/docs/githooks
The core. hooksPath config allows you to set a directory where the hooks are located for a repository. This is particularly useful if trying to commit your hooks to the repository (e.g. for sharing hooks with the team).
If the option is set in your local repository and you want to undo it, then git config --unset core. hooksPath is sufficient to unset it, which will make Git pick the default option.
All Git hooks are ordinary scripts that Git executes when certain events occur in the repository. This makes them very easy to install and configure. Hooks can reside in either local or server-side repositories, and they are only executed in response to actions in that repository.
The core.hooksPath
support is new in Git version 2.9, having been put in with commit 867ad08a2610526edb5723804723d371136fc643
. If your Git version is not at least 2.9.0, setting a hooks-path variable will have no effect at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With