项目名:web
一、自动触发
创建脚本:touch gitpull.sh
编辑脚本:vim gitpull.sh
1、在服务器添加脚本文件:gitpull.sh
#!/bin/sh
cd /www/web
git reset --hard origin/master
git clean -f
git pull 2>&1
git checkout master
# 注:若脚本文件路径不在www用户组的路径下,需要在www对应用户组路径下添加脚本文件
# 查看用户组路径(找到对应用户组即可):cat /etc/passwd
2、调用脚本(gitpull.sh
)回调接口:www.web.com/git-hook
<?php
exec('sh ~/gitpull.sh 2>&1', $a