The branch being pushed to is the first parameter to the update hook. If you want to lock the branch myfeature
for pushing, this code (placed in hooks/update
) will do it:
#!/bin/sh
# lock the myfeature branch for pushing
refname="$1"
if [[ $refname == "refs/heads/myfeature" ]]
then
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
echo "You cannot push to myfeature! It's locked"
echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
exit 1
fi
exit 0