How to propagate Git Hooks while cloning

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.

You can also configure Git to use a different directory for your hook scripts

git config --local core.hooksPath .hooks/

Leave a Comment