With git 2.9, you have a new option made for centralizing hooks: core.hooksPath
See commit 867ad08, commit de0824e, commit bf7d977, commit 49fa52f (04 May 2016) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano — gitster — in commit 6675f50, 17 May 2016)
The git config documentation now includes:
core.hooksPath
By default Git will look for your hooks in the ‘
$GIT_DIR/hooks‘ directory.
Set this to different path, e.g. ‘/etc/git/hooks‘, and Git will try to find your hooks in that directory, e.g. ‘/etc/git/hooks/pre-receive‘ instead of in ‘$GIT_DIR/hooks/pre-receive‘.The path can be either absolute or relative. A relative path is taken as relative to the directory where the hooks are run
This configuration variable is useful in cases where you’d like to
centrally configure your Git hooks instead of configuring them on a
per-repository basis, or as a more flexible and centralized
alternative to having aninit.templateDirwhere you’ve changed
default hooks.
The author of this pathc (Ævar Arnfjörð Bjarmason avar) adds in his commit:
I plan on using this on a centralized Git server where users can create
arbitrary repositories under/gitroot, but I’d like to manage all the
hooks that should be run centrally via a unified dispatch mechanism.
Git 2.10 uses that new setting in git rev-parse --git-path hooks/<hook>
See commit 9445b49 (16 Aug 2016) by Johannes Schindelin (dscho).
(Merged by Junio C Hamano — gitster — in commit d05d0e9, 19 Aug 2016)
rev-parse: respectcore.hooksPathin--git-path
The idea of the --git-path option is not only to avoid having to
prefix paths with the output of --git-dir all the time, but also to respect overrides for specific common paths inside the .git directory
(e.g. git rev-parse --git-path objects will report the value of the
environment variable GIT_OBJECT_DIRECTORY, if set).
When introducing the
core.hooksPathsetting, we forgot to adjustgit_path()accordingly. This patch fixes that.