why it is not possible to git add .git/hooks/my-hook

git, git-add, githooks

Solution

It is possible to define your own hooks in a git template, but even there, those hooks would be non-executable ones.

I.e. the user would still have to activate them (rename or activate the executable bit) once the repo is cloned. That way, said user won't have any unwanted script executed without his/her full knowledge and explicit approval. Doing otherwise would be too much of a security risk for anyone "blindly" cloning a repo.

Problem

I would like to have some hooks always present in a clone of a given repository. Is there a way to add a file in .git/hooks in the repository? Thanks

Original source

Related problems