blog

12021-04-10

SEAN K.H. LIAO

git hooks

git has hooks, useful for executing scripts on some events, like making sure everyone ran that formatter... Anyway, the problem is that it lives outside of version control and probably for good reason: if it's a symlink and references the main working space, checking out a different ref might change what hooks are run.

But you don't care, anyway, there are (or were) several projects to install them:

but the easiest way if you don't care about the symlink problem (or change to cp and pester collaborators to rerun every time you update it if you do) might just be something like this in a Makefile:

install-hooks:
        rm -rf .git/hooks
        ln -s ../hooks .git/hooks
        chmod +x hooks/*