Currently I'm using
git config --global core.hooksPath ~/.git/hooks
to configure global hooks for all my git projects. But if those projects contain hooks, they're not run.
I'd like to run the global hook as well as the project hooks. Thank you!
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.
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).
Git hooks are shell scripts found in the hidden . git/hooks directory of a Git repository. These scripts trigger actions in response to specific events, so they can help you automate your development lifecycle. Although you may never have noticed them, every Git repository includes 12 sample scripts.
This will need to be done per hook, but I confirmed it works for prepare-commit-msg
.
# run the global prepare-commit-msg if it is present
if [ -e `git config --global core.hookspath`/prepare-commit-msg ]; then
`git config --global core.hookspath`/prepare-commit-msg "$@"
fi
# otherwise do nothing
I'm using that with Husky 7 in a file at .husky/prepare-commit-msg
. Should work as a local hook as well.
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