Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git hooks management

Tags:

git

githooks

We use custom-written Git hooks in our project.

Hooks are stored in a project's repository, and, when they do change, to get a new version each user must copy them manually in his .git/hooks directory. This is rather inconvenient.

One way to improve this is to make .git/hooks a symlink into worktree. But this would imply that each branch (even user's local feature branches under development) should have the most current version of hooks. This is not convenient as well.

How would you solve the problem?

like image 949
Alexander Gladysh Avatar asked Jan 12 '10 16:01

Alexander Gladysh


People also ask

What are the git hooks?

Git hooks are scripts that run automatically every time a particular event occurs in a Git repository. They let you customize Git's internal behavior and trigger customizable actions at key points in the development life cycle.

Where are git hooks stored?

The hooks are all stored in the hooks subdirectory of the Git directory. In most projects, that's .git/hooks .

Can git hook scripts be managed along with the repository?

It will work, but it will not be managed along with the repository.


1 Answers

Maintain a separate repository of your hooks and symlink into that.

I agree, it'd be nice if Git had a built-in mechanism for propagating hooks scripts but it doesn't.

like image 137
Pat Notz Avatar answered Sep 28 '22 04:09

Pat Notz