4

Commit hooks in git live in the .git/hooks directory. What I would love is be able to commit those hooks so everyone checking out the repo has the hooks automatically. I'm not able to add the files inside .git/hooks to git however. Is this not at all possible?

I do realise there are server side hooks by the way, this is a theoretical quest :)

1
  • 2
    IMO that would introduce a security concern - people cloning your repo would get code executed without their knowledge. Rather, I suggest something not 10^2% automatic: commit the hooks to the repo itself and write a script to put (copy or move) the hooks in place. Of course it still requires you to instruct contributors to run that script by hand.
    – jweyrich
    Commented Jul 4, 2011 at 18:12

1 Answer 1

6

No, all you can do is have the hooks in the repo if needed and ask the owner of the repo to copy them to the .git/hooks ( or have another script in the repo that will copy the hooks ( or create symlink to them) , change permission etc. when it is run )

3
  • 3
    Or symlink them, like we do with phpBB: github.com/phpbb/phpbb3/tree/develop/git-tools/hooks
    – igorw
    Commented Jul 4, 2011 at 18:52
  • @igorw - thanks, forgot about symlink which is what I do, lol :)
    – manojlds
    Commented Jul 4, 2011 at 18:56
  • Thanks, I will then proceed to write a script which generates symlinks indeed.
    – hoppa
    Commented Jul 4, 2011 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.