是否可以使用部署网站git push
?我有预感这与使用有关git钩子 http://www.git-scm.com/book/en/v2/Customizing-Git-Git-Hooks执行一个git reset --hard
在服务器端,但我将如何实现这一点呢?
I found 这个脚本 https://stackoverflow.com/questions/279169/deploy-php-using-git/3387030#3387030 on 这个网站 http://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73而且看起来效果很好。
- 将 .git 目录复制到您的 Web 服务器
-
在本地副本上,修改 .git/config 文件并将 Web 服务器添加为远程服务器:
[remote "production"]
url = username@webserver:/path/to/htdocs/.git
在服务器上,将 .git/hooks/post-update 替换为这个文件 https://stackoverflow.com/questions/279169/deploy-php-using-git/3387030#3387030(在下面的答案中)
-
添加对文件的执行访问权限(同样在服务器上):
chmod +x .git/hooks/post-update
-
现在,只需在本地推送到您的网络服务器,它就会自动更新工作副本:
git push production
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)