我创建了一个git钩子,它可以侦听本地仓库上主分支上的任何新推送,并且只要找到它就会拉动服务器(部署Web应用程序)。
我引用了这个example来创建我的钩子。
以下是钩码:
档案名称&路径: .git / hooks / post-receive
#!/bin/sh
set -x
echo "Pulling new commits" >> hook_receive.log
while read oldrev newrev ref
do
if [[ $ref =~ .*/master$ ]];
then
echo "Master ref received. Deploying master branch to Test..."
unset GIT_DIR
git pull
else
echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server."
fi
done
我已经给出了文件执行权限:
chmod +x .git/hooks/post-receive
我为调试模式设置了set -x
标志,并且还尝试记录到文件hook_receive.log
,但没有记录任何内容。
我希望我使用正确的钩子。