Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 384
Marcin Avatar asked Feb 28 '14 16:02

Marcin


People also ask

Does Github support server side hooks?

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.

Can you commit pre-commit hooks?

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.

How do you put a pre-commit on a hook?

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.

What is git pre-commit hook?

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.


1 Answers

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.

like image 121
poke Avatar answered Oct 08 '22 02:10

poke