Git pre-receive hook

How to configure the global pre-receive hook on server side? I want to block a specific type of file pushing. I think this hook code will work fine ( But Don`t know how it will be configured in the server machine. I need a hand to achieve this.

Any suggestion?

Instruction on how to setup a pre-merge hook is explained in the following page.

@hozawa Yes, I got the way to configure the global hook by this link (

I created the new file pre-receive.d in the /opt/gitlab/embedded/service/gitlab-shell/hooks and added the below two line to check if the hook working or not,

 #!/usr/bin/env bash
 echo "test bash hook"

But I didn`t get the above text in the git push screen. How can I confirm is this hook working or not?

Have you make the hook file executable? like chmod +x

Hi folks.
I am also facing same issue with pre-recive hook which i make as executable file and also followed.
``mkdir -p /gitlab-shell/hooks/pre-receive.d
chown git:git /gitlab-shell/hooks/pre-receive.d

link or copy your script of course it needs to be executable by the Gitlab user

symlink to one common script

ln -s /usr/bin/my-hook /gitlab-shell/hooks/pre-receive.d/my-hook

while  am testing with users by pushing the confidential information they are able to do it.

Please help me over come this problem.