Git pre-launch hook not working

I placed a file inside .git / hooks named pre-push.sh

I do not do any checks, I just want to repeat the error when I press the remote control. Below is the contents of the .sh file

protected_branch='test'
echo $protected_branch
exit 1

However, it still allows you to push changes without any error. Need help finding where I am making a mistake?

+5
source share
3 answers

The name of the hook must be accurate pre-push(no pre-push.sh, no pre-push.exe, no pre-push.py...)

+9
source

pre-push.shis not a valid name. Instead, it must be hosted on the server as pre-receive.

+5
source

, ,

chmod 766 .git/hooks/pre-push

.

+1

All Articles