Setting pre-commit-hook server side

帅比萌擦擦* 提交于 2019-12-11 01:29:34

问题


Is it possible to set up pre-commit-hooks in the server repo and have them download to the clients when the repo is cloned?


回答1:


From git-scm:

The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that’s .git/hooks.

Recall that .git/ is managed locally.

So, no, there is no programmatic way using only git to force a repository to install hooks when it is cloned.

That said, a common practice is to bundle hooks into a folder like hooks/ within your repository, and then either

  • explain how to install them in the README, or
  • provide a script which will install them after cloning that the user has to run manually.

If you have rules you wish to validate, which you could use to smoke-test if someone has used a hook, you can install pre-receive hook in your remote.

For example, if you have a pre-commit hook that prepends a branch identifier to commit messages, you could check in a pre-recieve hook (actually on the 'server') that commit messages start with a branch identifier.



来源:https://stackoverflow.com/questions/47182740/setting-pre-commit-hook-server-side

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