How can I create a global pre-commit hook that is available for everyone in the team to use? Basically, I want that anytime someone clones the remote repository he should ge
How can the
pre-commit
hook be made available to entire team by default?
It can not, as I explained in "Difference between pre-push and pre-receive hook in git?"
And from a security standpoint, that'd be really kind of scary - no one should have the ability to force me to execute certain scripts whenever I run certain git commands
So:
--template
option of git clone
.But in any case, remember that a git commit --no-verify would bypass the pre-commit hook anyway.
That is why a server-side hook is safer (as discussed in "Difference between pre-push and pre-receive hook in git?") and will catch all bad commits pushed to a blessed repo.
That is not say a pre-commit hook is useless: if you can convince the users to activate it, it will help catch error sooner, which is a good thing.
But it cannot be enforced "automatically".
Luckily there is not a way to force hooks to people upon clone
.
If there was, you could write a post-receive
hook with rm -rf /
in it and wipe people's hard disk on pull