As I mentioned in "Git commit hooks - global settings" and "change default git hooks" last May 2016, Git 2.9 and 2.10 introduced git config core.hooksPath
.
That seems to confuse the OP:
If I have an existing repo and want all other dev's who pull changes to have an updated pre-commit hook for example how would I do this ?
Within the repo there is /.git/hooks/pre_commit
, can I point it to that
More precisely, within a git repo, there is a /.git/hooks/pre-commit.sample
and, considering you want a common pre-commit
hook for all developers, you should not make and then point to a /.git/hooks/pre_commit
script within your local repo.
All developers have to reference the same gobal shared network-accessible path used with git config core.hooksPath \\a\common\shared\path
: that setting needs to be activated on each developer workstation, either within their repo (local setting) or for all their repo (global setting: git config --global core.hooksPath \\a\common\shared\path
.
(I use here a Windows UNC syntax, use the one suited for your OS)
Once they all reference the same path, you can set up your pre-commit hook there:
\\a\common\shared\path\pre-commit
Then you can update that script (the one accessed by everyone), allowing all developers to benefit instantly of the updates.