简体   繁体   English

如何设置它,以便在对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?

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. 我们认为git是最好的选择,因为我们俩都已经知道如何使用它。 What we want to do is set up a github repository that automatically syncs with the production server when we make changes. 我们要做的是设置一个github存储库,当我们进行更改时,该存储库会自动与生产服务器同步。 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/ 当您推送到您的仓库时,可以让github与远程主机通信: 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. 因此,您可以编写自己的请求处理程序以接受他们发布给您的JSON,并开始更新存储库的服务器端检出并以某种方式进行更新的过程。 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. 可能需要格外小心,以确保服务器在进行更新时不会错误地配置自身,但是如果您只是更新PHP文件,则应该可以。

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 . 也就是说,您只是说“ ref”等于“ refs / heads / master”,如果是,则将cd检出到您的PHP文件并执行git fetch githubgit reset --hard $after_rev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM