Michael
Michael

Reputation: 415

Location of server-side .git/hooks folder

I need to monitor changes in multiple Git repositories. I know it can be done with so called 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. 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?

Upvotes: 2

Views: 1374

Answers (2)

kostix
kostix

Reputation: 55553

There is no such thing as "client-side" and "server-side" Git repositories.

The difference—when it exists—is that typically server-side Git repositories are created to be "bare" (see 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. (And that's why when creating a bare repository by hand, it's customary to give it a name ending in ".git".)

So when a regular repository has ".git/hooks" your server-side repository merely has "hooks"—right there in the repository's directory.

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. 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).

Upvotes: 2

Michael Wild
Michael Wild

Reputation: 26381

The server side hooks are located in the hooks directory of your bare remote repository, e.g. repo.git/hooks/.

Upvotes: 2

Related Questions