I've looked around the answers on SO, and the web, and I can't see anything on how to set up a server-side git hook on github (as opposed to webhooks). Is there a way to do this?
Or alternatively, is there a way to set it up so that .git/hooks is a symlink to a part of the working tree at the time of cloning?
I should add that this is an internally-hosted github server.
You can install server-side hooks from your Git repository's Settings sub-tab and then opening the Server-Side Hooks page from the left side of the screen. We already have some hooks that you can install and view their code sources as well.
pre-commit hooks are a mechanism of the version control system git. They let you execute code right before the commit. Confusingly, there is also a Python package called pre-commit which allows you to create and use pre-commit hooks with a way simpler interface.
Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.
The pre-commit script is executed every time you run git commit before Git asks the developer for a commit message or generates a commit object. You can use this hook to inspect the snapshot that is about to be committed.
For obvious reasons, GitHub won’t allow you to execute arbitrary code on their servers as part of Git hooks. The only hooking they allow is through their webhooks or the integrated third-party services.
If you need to run some custom code, you will have to host that somewhere and set up a webhook to run it on your own server.
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