简体   繁体   English

服务器端.git / hooks文件夹的位置

[英]Location of server-side .git/hooks folder

I need to monitor changes in multiple Git repositories. 我需要监视多个Git存储库中的更改。 I know it can be done with so called git-hooks. 我知道可以用所谓的git-hooks完成。 Searching the internet (here, GitHub, ...) I found something in the Atlassian tutorials: https://www.atlassian.com/git/tutorials/git-hooks/server-side-hooks . 搜索互联网(在这里,GitHub,...),我在Atlassian教程中找到了一些东西: https : //www.atlassian.com/git/tutorials/git-hooks/server-side-hooks However, I just can't find where they are located. 但是,我只是找不到它们的位置。 As far as I understand, they should be located somewhere, since they are opened to developers, at least according to what the text hints. 据我了解,它们应该位于某个地方,因为它们至少是根据文本提示向开发人员开放的。 So, anyone knows where to find them? 那么,谁知道在哪里可以找到它们?

服务器端挂钩位于裸露的远程存储库的hooks目录中,例如repo.git/hooks/

There is no such thing as "client-side" and "server-side" Git repositories. 没有“客户端”和“服务器端” Git存储库。

The difference—when it exists—is that typically server-side Git repositories are created to be "bare" (see git help init ). 不同之处(如果存在)是通常将服务器端Git存储库创建为“裸机”(请参阅git help init )。 Such repositories differ from "normal"—those you usually find on the developers' machines in that they do not contain the work tree—the place where the files are checked out and got modified by the developer. 此类存储库不同于“普通”存储库(您通常在开发人员的计算机上找到这些存储库是因为它们不包含工作树),即文件被开发人员检出并修改的地方。

So while a regular Git repository consists of the work tree and the directory named ".git" with the repository itself immediately under the work tree, bare repositories are directly what regular repositories contain in their ".git" subdirectories. 因此,尽管常规Git存储库由工作树和名为“ .git”的目录组成,并且存储库本身直接位于工作树下,但裸存储库直接是常规存储库包含在其“ .git”子目录中的内容。 (And that's why when creating a bare repository by hand, it's customary to give it a name ending in ".git".) (这就是为什么在手工创建裸仓库时,通常给它一个以“ .git”结尾的名称的原因。)

So when a regular repository has ".git/hooks" your server-side repository merely has "hooks"—right there in the repository's directory. 因此,当常规存储库具有“ .git / hooks”时,服务器端存储库仅具有“ hooks”,就在存储库目录中。

Note that all of the above only holds true if you serve your server-side repositories directly with Git or with a "simple" front-end to it, such as gitolite . 请注意,只有当您直接使用Git或带有“简单”前端(例如gitolite服务器端存储库时,上述所有条件才成立。 Advanced 3rd-party hosting solutions might use different means to serve such repositories and have different ideas about what "the hook" means to them. 先进的第三方托管解决方案可能会使用不同的方法来服务此类存储库,并且对“挂钩”的含义有不同的看法。 I mean, Git hooks are only called by Git when it's launched to serve a push to or a fetch from a repository). 我的意思是,Git挂钩仅在启动时才由Git调用,以服务于对存储库的推送或获取。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM