I'm trying to have one repo with all my githooks and every other repo references that.
My repo directory structure looks like this.
~/dev/githooks/.git/hooks
|-> pre-push
|-> prevent-master
prevent-master
#!/bin/sh
branch_blocked="master"
if grep -q "$branch_blocked"; then
echo "Branch '$branch_blocked' is blocked by yourself." >&2
exit 1
fi
Now I tell my git config to use this githook directory git config core.hooksPath ~/dev/githooks/.git/hooks
In a separate repo I'm trying to push and it says
clickthisnick$ git push
fatal: cannot exec '/Users/clickthisnick/dev/githooks/.git/hooks/pre-push': Permission denied
I have chmod -R +xr ~/dev/githooks
and am using a git version that supports this git version 2.17.2
.
Anything else I can try to get this to work?
chmod
ed is not the path to your hooks (~/dev/githooks.git
vs~/dev/githooks/.git
)...ls -l /Users/clickthisnick/dev/githooks/.git/hooks/pre-push
?-rwxr-xr-x 1 clickthisnick staff 149 Jan 2 15:02 prevent-master