I have a git server. Not gitlab or something similar, bare git server. I wanted to create git hook to decline push on master branch for certain users. I tried to do that with below one.
#!/bin/bash
if [ "$1" == refs/heads/master ];
then
CEMAIL=$(git log -1 --format=format:%ce HEAD)
echo $CEMAIL
if [ "$CEMAIL" != [email protected] ] && [ "$CEMAIL" != [email protected] ];
then
echo "-----------------------------------------------------"
echo "WARNING: You are not allowed to Push in MASTER branch !"
echo "-----------------------------------------------------"
exit 1
fi
fi
Users without above email should not be able to push on master branch. But It is not working as expected. Can you guys please guide me about it ?
UPDATE: When i ([email protected]) it will allow me to push to the branch. And then if i ask someone else to push to the branch other than me and jake, then it allows too. It picks the last users email.
0 Answers