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?
Your git hook needs to be an executable file , not a directory. git will try to invoke:
/Users/clickthisnick/dev/githooks/.git/hooks/pre-push
But you have this configured as a directory, containing a hook ( prevent-master
) not a file. Instead, rename:
/Users/clickthisnick/dev/githooks/.git/hooks/pre-push/prevent-master
to
/Users/clickthisnick/dev/githooks/.git/hooks/pre-push
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.