Git 直接推送到生产服务器

假设路径为/project/path/

设定git仓库可以直接被远程推送(需要较新的git版本,比如2.7)

cd /project/path
git config receive.denyCurrentBranch updateInstead

设定本仓库被远程push之后的行为

cd .git/hooks
echo -e '#!/bin/bash\n/usr/local/openresty/nginx/sbin/nginx -p /project/path -c /project/path/conf/deploy.conf -s reload' >> post-receive

设定为可执行

chmod a+x post-receive

设定本仓库本地pull之后的行为

cp post-receive post-merge

完工

posted @ 2016-12-16 17:16  LisPythoniC  阅读(567)  评论(0编辑  收藏  举报