Reputation: 139
Is it possible to set up pre-commit-hooks in the server repo and have them download to the clients when the repo is cloned?
Upvotes: 3
Views: 4604
Reputation: 12227
From git-scm:
The hooks are all stored in the
hooks
subdirectory of the Git directory. In most projects, that’s.git/hooks
.
Recall that .git/
is managed locally.
So, no, there is no programmatic way using only git to force a repository to install hooks when it is cloned.
That said, a common practice is to bundle hooks into a folder like hooks/
within your repository, and then either
If you have rules you wish to validate, which you could use to smoke-test if someone has used a hook, you can install pre-receive
hook in your remote.
For example, if you have a pre-commit hook that prepends a branch identifier to commit messages, you could check in a pre-recieve hook (actually on the 'server') that commit messages start with a branch identifier.
Upvotes: 2