我在虚拟服务器上编写了以下接收后挂钩,以便它将存储库的开发和生产版本复制到运行每个版本的站点的开发和生产目录中。
以下是我写的post-receive hook。如何根据刚刚推送的分支有条件地刷新一个或另一个?
#!/bin/sh
if [ -n $GIT_DIR ]; then
unset GIT_DIR
cd ..
fi
echo "Deploying to dev"
git checkout develop
umask 002 && git reset --hard
cp -r /path/to/git/files/* /path/to/dev/site/
echo "Deploying to prod"
git checkout master
umask 002 && git reset --hard
cp -r /path/to/git/files/* /path/to/prod/site/