On Thursday, August 16, 2012 6:25:11 PM UTC+2, Bryce wrote:
> Hi all,
> I was just curious if anyone is aware of best practices for sharing git
> hooks within a project.
> For example, say I wanted everyone to use the same pre-commit hook,
> would I just add it to the repo?
I think you just have to store it somewhere everyone can access it.
If it's a hook which is only supposed to be used in one project/repo, sure,
check it into the repo, and inform everyone (and write it in the readme.txt
of the repo or something) that they have to copy it into the .git/hooks
folder after cloning.
If it is shared across several projects, you probably want to put it
somewhere a bit more global. At our place we have a company-settings.git
repository that each developers clones when setting up their machine. Here
we put global settings files, along with some scripts for quickly
installing them into the developer's systems. You could combine this with
the --template argument mentioned by Pankaj above.
Note that you can also use --template with git clone.
And finally: Don't put too much stuff into people's local hooks. You don't
want to tie a ball and chain around their foot. If the commit hook runs a
10-minute long code-quality-check before committing, it will hurt more than
it helps. This is why we don't enforce *any* local commit hooks for the
developers at our place.
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To view this discussion on the web visit
To post to this group, send email to firstname.lastname@example.org.
To unsubscribe from this group, send email to
For more options, visit this group at