Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add git hook to the remote repository?

I've created a pre-commite hook and it works on my local machine, but I don't know how can I share this hook with my collegs

I will be grateful for any help.

Thanks in advance Denis

like image 712
Denys Medvediev Avatar asked Sep 19 '16 10:09

Denys Medvediev


1 Answers

It’s important to note that client-side hooks are not copied when you clone a repository.

On Server side, the 1st hook is pre-receive.

Not everything is possible in this one, depending on what you want to do before the commit, but that's the place to do stuff if you want to do it for everybody who use the repository.

Note: You have to have access to the git server to do that.

Edit:

For global settings, take a look at https://stackoverflow.com/a/8842663/3445619 But this solution requires a new git init to be done by everyone.

If you don't have access to the git server or want to apply code ruler/styler, I would recommend to ask your colleague to make a link from .git/hooks/pre-commit to a versioned file where you can edit your own pre-commit hook for everyone. Or simply share your file with them, if it will never change. (But this will have to be done for every newcomers).

like image 83
Simon PA Avatar answered Sep 30 '22 08:09

Simon PA