github 服务器端 git hooks(即预提交和后提交)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22100581/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:47:17  来源:igfitidea点击:

github server-side git hooks (i.e. pre-commit and post-commit)

gitgithubgithooksgithub-enterprise

提问by Marcin

I've looked around the answers on SO, and the web, and I can't see anything on how to set up a server-side git hook on github (as opposed to webhooks). Is there a way to do this?

我环顾了 SO 和网络上的答案,但看不到任何有关如何在 github 上设置服务器端 git hook(而不是 webhooks)的信息。有没有办法做到这一点?

Or alternatively, is there a way to set it up so that .git/hooks is a symlink to a part of the working tree at the time of cloning?

或者,有没有办法设置它,以便 .git/hooks 是克隆时工作树的一部分的符号链接?

I should add that this is an internally-hosted github server.

我应该补充一点,这是一个内部托管的 github 服务器。

回答by poke

For obviousreasons, GitHub won't allow you to execute arbitrary code on their servers as part of Git hooks. The only hooking they allow is through their webhooks or the integrated third-party services.

出于显而易见的原因,GitHub 不允许你在他们的服务器上执行任意代码作为 Git 钩子的一部分。他们允许的唯一钩子是通过他们的网络钩子或集成的第三方服务。

If you need to run some custom code, you will have to host that somewhere and set up a webhook to run it on your ownserver.

如果您需要运行一些自定义代码,则必须将其托管在某处并设置一个 webhook 以在您自己的服务器上运行它。