user3552178 user3552178 - 3 years ago 122
Git Question

How to permanently commit and push git hook file?

i want to have a post-checkout in .../.git/hooks permanently, so when others do a clone, they can get it as well.

How should i do that please ? guess this has to happen in the git server side ? Many thanks !

Answer Source

You can't, and I'll tell you why: clone my repository that installs a post-checkout hook that immediately removes your entire home directory.

Allowing git clone to execute arbitrary actions based on what was downloaded is a gaping security hole, and that's why Git does not do it. Or rather, why Git does not do it now—it was, by mistake, possible in the past on systems that did case-folding during file system lookup. But it must not be allowed.

What you can do is include in your repository a program that, when voluntarily run by whoever clones the repository, installs a hook—and then give your users instructions that they should run this program themselves. You cannot force them to do it; you can only make it easy for them. But they must do this of their own volition, perhaps after inspecting your code to make sure it is safe.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download