#!/bin/bash
TARGET="/home/webuser/deploy-folder"
GIT_DIR="/home/webuser/www.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
什么#!/bin/bash
?没有它一切正常,这条线有多重要?对问题的 PS无法运行 hooks/post-receive: No such file or directory
这是 一个shebang (英文“ shebang ”):
至于重要性,如果你运行你的脚本是必要的
./myscript
,如果你运行bash ./myscript
它,它提供了将读者指向解释器的纯粹信息功能。