Back

Explore Courses Blog Tutorials Interview Questions
+2 votes
2 views
in DevOps and Agile by (19.4k points)

We'd like to make a few basic hook scripts that we can all share -- for things like pre-formatting commit messages. Git has hook scripts for that that are normally stored under <project>/.git/hooks/. However, those scripts are not propagated when people do a clone and they are not version controlled.

Is there a good way to help everyone get the right hook scripts? Can I just make those hook scripts point to version-controlled scripts in my repo?

1 Answer

+1 vote
by (27.5k points)

First, move your hooks to a hooks tracked directory in your repository. Now configure each instance of the repository to use the tracked hooks instead of $GIT_DIR/hooks:

git config core.hooksPath hooks

In general, the path may be absolute, or relative to the directory where the hooks are run.

Browse Categories

...