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

余生颓废 提交于 2019-11-28 10:53:14
VonC

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!