github server-side git hooks (i.e. pre-commit and post-commit)

Marcin picture Marcin · Feb 28, 2014 · Viewed 14.8k times · Source

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.

Answer

poke picture poke · Feb 28, 2014

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.