当我“git push”时,git钩子是否被推送到遥控器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12222186/
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-10 14:30:07  来源:igfitidea点击:

Are git hooks pushed to the remote when I 'git push'?

gitgithooks

提问by slacy

If I create a new hook script in my local repository in repo/.git/hooks/post-commit and then I run "git push" are the hooks pushed to the remote? Then, when the other developers run "git pull" from the same origin will they get my new hooks?

如果我在 repo/.git/hooks/post-commit 的本地存储库中创建一个新的钩子脚本,然后运行“git push”,钩子是否推送到远程?那么,当其他开发人员从同一个来源运行“git pull”时,他们会得到我的新钩子吗?

采纳答案by Lily Ballard

No. Hooks are per-repository and are never pushed. Similarly, the repo config isn't pushed either, nor is anything in .git/info, or a number of other things.

不。钩子是每个存储库,永远不会被推送。同样, repo 配置也不会被推送, 中的任何东西.git/info或其他一些东西也不会被推送。

Pushing and pulling only exchanges branches/tags and commit objects (and anything reachable from a commit, e.g. trees, blobs).

推和拉只交换分支/标签和提交对象(以及任何可从提交访问的东西,例如树、blob)。

回答by Marco Leogrande

No, git hooks are not pushed or pulled, as they are not part of the repository code.

不,git 钩子不会被推或拉,因为它们不是存储库代码的一部分。

Please refer to the documentationfor a list of simple client-side and server-side hooks.

请参阅文档以获取简单的客户端和服务器端挂钩列表。

If you want to enable some hooks for all clients that clone or pull from a given repository, you have to add the hooks to your codebase and then create your own script to copy them into, or link to them from repo/.git/hooks/.

如果要为从给定存储库克隆或拉取的所有客户端启用某些挂钩,则必须将挂钩添加到代码库中,然后创建自己的脚本以将它们复制到repo/.git/hooks/.