Git 直接推送到生产服务器

假设路径为/project/path/

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

cd /project/path
git config receive.denyCurrentBranch updateInstead

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

cd .git/hooks
echo -e '#!/bin/bash /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

完工

原文地址:https://www.cnblogs.com/xiangnan/p/6187740.html