使用Git推送部署项目 [英] Deploy a project using Git push
问题描述
可以使用 git push
部署网站吗?我有一个预感,它与使用 git hooks有关在服务器端执行 git reset --hard
,但是我该如何完成这个?
Is it possible to deploy a website using git push
? I have a hunch it has something to do with using git hooks to perform a git reset --hard
on the server side, but how would I go about accomplishing this?
推荐答案
I found this script on this site and it seems to work quite well.
- 将您的.git目录复制到您的Web服务器
-
在本地副本上,修改您的。 git / config文件,并将您的Web服务器添加为远程:
- Copy over your .git directory to your web server
On your local copy, modify your .git/config file and add your web server as a remote:
[remote "production"]
url = username@webserver:/path/to/htdocs/.git
在服务器上,替换。 git / hooks / post-update with 此文件(在下面的答案中)
将执行访问权限添加到文件(再次,在服务器上):
Add execute access to the file (again, on the server):
chmod +x .git/hooks/post-update
现在,只需在本地推送到您的Web服务器,它应该自动更新工作副本:
Now, just locally push to your web server and it should automatically update the working copy:
git push production
这篇关于使用Git推送部署项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!