1

I have Gitlab setted locally on my server. I noticed, that when i am adding some code to "post-receive" file in some repository, all changes applying to all other repositories in that group.

How to stop it?

lucas63
  • 95
  • 1
  • 11

1 Answers1

1

Check the "Custom Git hooks setup":

Normally, Git hooks are placed in the repository or project's hooks directory. GitLab creates a symlink from each project's hooks directory to the gitlab-shell hooks directory for ease of maintenance between gitlab-shell upgrades.

This explains why your hook seems to be propagated to all repos of the group.

Follow the steps below to set up a custom hook:

  • Pick a project that needs a custom Git hook.
  • On the GitLab server, navigate to the project's repository directory. For an installation from source the path is usually /home/git/repositories/<group>/<project>.git.
    For Omnibus installs the path is usually /var/opt/gitlab/git-data/repositories/<group>/<project>.git.
  • Create a new directory in this location called custom_hooks.
  • Inside the new custom_hooks directory, create a file with a name matching the hook type.
    For a pre-receive hook the file name should be pre-receive with no extension.
  • Make the hook file executable and make sure it's owned by git.
  • Write the code to make the Git hook function as expected
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • i have problem. Now, my hooks doesnt work. I have changed owner of folder, owner of hook, all names are actual, i have make hook executable. I am using post-receive to deploy code to folder(/etc/*destination_folder/), even grant 777 permission for folder to which i want deploy, but it doesnt work. Can you say something about this problem? – lucas63 Mar 06 '17 at 13:14
  • "my hooks doesnt work." Do you have an error message? Try adding some echo to your hooks to see if they are executed (and an `env` command to see with which environment variables that script is working with) – VonC Mar 06 '17 at 13:22
  • how to check it?When i use this hook as global for all projects - it was working perfectly – lucas63 Mar 06 '17 at 13:23
  • @lucas63 Basically, on Stack Overflow, just saying "it does not work" is not enough: what do you expect, what do you see, with which exact configuration: ask a new question with *all* those details and we can help you. – VonC Mar 06 '17 at 13:24