Emmel
Emmel

Reputation: 298

Is there a way to have git pre-push hooks on GitHub? Or Workarounds?

Goal: I need to enforce a pre-push hook on my GitHub-hosted repository branches, which have collaborators, and unfortunately I can't find a way to get that hook to find its way into my collaborators' and my own .git/hooks directory.

I've spent time researching this issue and I've come across the following blockers:

Popular wisdom wants me to: push out the pre-push script in a different directory, and kindly ask my collaborates to symlink it. No! I need this to automatically populate.

I know myself better than git knows me. How do I override the nanny protections so I can do what I need to do here? Is there some magic with templates?

EDIT: or any other creative solutions (services, integrations, webhooks, assuming they don't require setting up a server to talk back to!).

Upvotes: 2

Views: 504

Answers (1)

1615903
1615903

Reputation: 34732

You cannot do it with GitHub. As you have noticed, GitHub doesn't have server-side hooks, so that wont do. And for putting scripts in the repository that would automatically run for other users, well, that would be a HUGE security risk and it's obviously not possible to do with git.

You may try switching to another hosting solution that does allow server-side hooks, such as GitLab.

Upvotes: 2

Related Questions