如何设置它,以便在对github存储库进行更改时自动更新生产服务器上的项目? [英] How can you set it up so that your project automatically updates on your production server when you make changes to a github repository?

查看:108
本文介绍了如何设置它,以便在对github存储库进行更改时自动更新生产服务器上的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始与另一位开发人员合作,我们正在讨论不同的版本控制解决方案,以便我们的项目更顺利。我们认为git是最好的选择,因为我们都知道如何使用它。我们想要做的是设置一个github存储库,当我们进行更改时,它会自动与生产服务器同步。有没有办法做到这一点?只要在正确的方向寻找一个点?

解决方案

当您推送到回购站时,您可以让github与远程主机通信:
http://help.github.com/post-receive-hooks/

因此,您可以编写自己的请求处理程序来接受他们提交给您的JSON,并启动更新服务器端结帐的过程回购,并以某种方式更新自己。在进行更新时,需要注意确保服务器不会自行配置错误,但如果您只是更新PHP文件,则应该可以。



也就是说,你只是ref等于refs / heads / master,如果是的话,cd到你的PHP文件被检出的地方,并执行 git fetch github git reset --hard $ after_rev


I just started working with another developer and we were talking about different version control solution so our projects will go smoother. We decided that git was the best option since we both knew how to use it already. What we want to do is set up a github repository that automatically syncs with the production server when we make changes. Is there a way to do this? Just looking for a point in the right direction?

解决方案

You can have github communicate to a remote host when you push to your repo: http://help.github.com/post-receive-hooks/

So you can then write your own request handler to accept the JSON that they post to you, and kick off the process of updating a server-side checkout of the repo, and somehow updating itself. Some care may need to go into making sure that the server doesn't misconfigure itself while taking an update, but if you're just updating PHP files you should be OK.

That is, you just that the "ref" is equal to "refs/heads/master", and if so, cd to where your PHP files are checked out and do git fetch github, git reset --hard $after_rev.

这篇关于如何设置它,以便在对github存储库进行更改时自动更新生产服务器上的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆