I'd like to add a git hook to a project of mine. I have created it (.git/hooks/pre-push) and it works locally.
Now how can I include it to the repo so when I push the project to GitHub other people can get the hook upon cloning the repo?
Even if I do not have a .gitignore file the .git folder is automatically ignored
Thanks
The directory .git/hooks
is not part of your working directory and therefore is not committed nor pushed to the repo.
What you can do is to create (in your working directory) shell script file that will create the needed hooks and then ask the other developers or users to execute the file and create the hooks.
Additionally GitHub and Bitbucket and similar allow you to create web hooks that trigger at certain conditions. Here you can read more about the web hooks : https://developer.github.com/webhooks/
If you are using Bitbucket even in the free service there is a feature to set permissions which user can push to which branch. Check limit the push powers
My usual approach is to create separate branch for each developer or company and to allow them to push only in their own branch. Then the project manager or the lead developer can decide which branch when to merge into the master.
This way the code is very easily manageable.
GitHub is lacking some of the features of Bitbucket, but in this case the same type of control can be achieved if you ask all the developers to fork the repo, then work in their own forked repos and once ready to create pull requests so the project manager or the lead developer can review and merge the repos or create issues to be fixed.
This is known as fork and pull
GitHub model, here you can read more about it: https://help.github.com/articles/using-pull-requests/#fork--pull
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With