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

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

  • How does git-svn behave with svn repositories that have changed layout?
  • Git ref master now empty, how to recover?
  • Why has Git allowed me to create two branches with the same name?
  • What is the difference between author and committer in Git?
  • Jenkins configuration
  • Removing large file from git history?
  • Why is this git shallow clone bigger than I expected?
  • ldap authentication with gitblit 1.0
  • Git 2.4.8 built from kernel.org sources and missing HTTP/HTTPS helpers
  • Git pushing to remote GitHub repository as wrong user
  • How to “reopen” the last git commit?
  • IntelliJ IDEA GitHub integration creates the repository, but gets “couldn't authorize” error trying to push
  • 2 Solutions collect form web for “why it is not possible to git add .git/hooks/my-hook”

    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.

    Sounds like a security risk to me. Just because you clone some repository doesn’t mean you want to give it the right to execute code.

    You could put a copy of hooks into the versioned code and include some script file to allow the user to copy them to his hooks directory easily. And of course one you have hooks installed you can use them to keep themselves up-to-date.

    Git Baby is a git and github fan, let's start git clone.