1

I would like to set up pre-commit hook in all my projects under my organization . I googled and found I have to do that manually for each project . Is there a way to set up these hooks across all projects under my organization . Also If I can add these hooks automatically when I create new projects will be more helpful.

adorearun
  • 151
  • 1
  • 13
  • 1
    Possible duplicate of [Git remote/shared pre-commit hook](https://stackoverflow.com/questions/3703159/git-remote-shared-pre-commit-hook) – max630 Sep 20 '17 at 03:38

2 Answers2

2

If you place all your hooks in a template directory, you can set up git so that it uses these hooks when creating or cloning a new repo. Only works for client-side hooks though.

You can either use the --template=/path/to/templatedir option when using git-init or git-clone or add the following lines to your .gitconfig:

[init]
    templatedir = /path/to/templatedir
Aratz
  • 430
  • 5
  • 16
1

GitHub (almost) only supports client-side hooks (they don't allow you to use your own server-side hooks). Client hooks, like pre-commit, are something you would configure not just for each repo, but for each user's clone of that repo.

When I say "almost" it's because they also support some predefined hooks for "Protected Branches". You may be able to use protected branches and a custom status check to build what you need.

heph
  • 81
  • 3