By default, it looks like this is empty when run in a git repo root:
git config core.hooksPath
If we change git config core.hooksPath to git config core.hooksPath myhooks
, my question is - how do we change it back to the default? Should we unset the value (how?), or should we set it to .git/hooks
as in git config core.hooksPath .git/hooks
?
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).
No. Hooks are per-repository and are never pushed.
The answer depends on where it's set and what you want to change. 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.
If the option is set in a higher level configuration (e.g., per-user or per-system) and you don't want to remove it from that location, only override it for this repository, you can use git config core.hooksPath .git/hooks
if you are in a non-bare repository or git config core.hooksPath hooks
if you are in a bare repository.
From git-config(1)
:
The path can be either absolute or relative. A relative path is taken as relative to the directory where the hooks are run.
From githooks(5)
:
Before Git invokes a hook, it changes its working directory to either $GIT_DIR in a bare repository or the root of the working tree in a non-bare repository.
Hence the requirement for .git/hooks
in a non-bare repository and hooks
in a bare one.
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