Hacker News new | ask | show | jobs
by spenuke 3610 days ago
It's hard to completely generalize for the clobbering reason you point out.

Assuming that you essentially want to keep your hooks coupled with your source code (or, at least, it's ok to do so), I've found that Make works pretty well here.

In the root of the project directory, you have a subdirectory containing all the hooks you need (or use a git submodule), and then you create a Make target to copy those hooks (and make them executable) to your .git/hooks directory. Make is nice because it won't clobber existing ones (unless they are older, in which case you probably want them overwritten).

Then, whenever someone first clones the repo (or whenever you make a change to the hooks), they just need to run make on that target again.

Obviously, not an ideal choice for everyone, but it's pretty simple and works well for me.