How to propagate Git Hooks while cloning

baluchen picture baluchen · May 12, 2011 · Viewed 8.9k times · Source

I've written a pre-commit hook in my central repository. When my clients clone the repository it never propagates the hooks. I would like the hooks to also be copied to my clients' repositories. My clients are Windows users, using msysgit as the git client.

Is there any way I can get the hooks copied to local repositories?

Answer

iconoclast picture iconoclast · Jun 25, 2012

You could write a setup script, e.g. setuphooks.sh, that pulls down the hook scripts and installs them in the right places. It shouldn't be hard to write, as curl could do most of the work.

Or you could just include the hooks in the repo in a normal folder like .hooks, and copy them all to .git/hooks.

Others have suggested you symlink them, but that poses problems for users of Windows.