当Github收到更新时,将其推送到远程服务器 [英] Make Github push to a remote server when it receives updates

查看:222
本文介绍了当Github收到更新时,将其推送到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设置Github是否会自动将更新推送到远程服务器?

这对于在Github上维护代码库并使网站运行非常有用关闭该代码库。


  1. 我在自己的电脑上有我的回购,这是我工作的地方。


  2. 我在本地回购库上进行更改,并将它们推送到我的Github回购库。

  3. 我想要我的Github仓库,然后将这些更改推送到我的远程服务器。


我一整天都在研究,使用'钩子'听起来很合理。可能在Github上使用'post-receive'钩子,然后向我的远程服务器运行push命令。



有什么建议?

webhook 的东西。你可以用这个做什么,只要有一个推送到你的版本库,就向你指定的任何URL发出一个web请求。



所以你可以做的是:设置一个webserver在你的远程git服务器上,并配置github在post-receive上对它进行http调用。每当github通知您的远程服务器时,请从github上获取它。



请参阅这里了解如何使用webhooks: https://help.github.com/articles/post-receive-hooks



PS
一个真正的hook机器人主义已经成为github的一个可能的安全漏洞,因为它允许你在他们的服务器上执行自定义代码。所以他们做了一些不允许你执行任何操作的东西,但仍然允许你做任何你想做的事情。


What is the set up for having Github automatically push any updates to a remote server?

This is useful for maintaining a codebase on Github, and having a website run off that codebase.

  1. I have my repo on my own computer, this is where I work.

  2. I commit my changes on my local repo, and push them to my Github repo.

  3. I want my Github repo to then push these changes to my remote server.

I've been researching all day, and using the 'hooks' sounds reasonable. Maybe using a 'post-receive' hook on Github which then runs a push command to my remote server.

Any suggestions?

解决方案

As I understand github doesn't allow you to define "true" hooks. Like post-receive. Instead they provide something called a webhook to developers. what you can do with this is issue a web request to any URL specified by you whenever there's a push to your repository.

So what you can do is: setup a webserver on you remote git server and configure github to make an http call to it on post-receive. Whenever github notifies your remote server do a pull on it from github.

See here on how to use webhooks: https://help.github.com/articles/post-receive-hooks

P.S. A true hook mechianism whould have been a possible security vulnerability for github cause it allows you to execute custom code on their servers. So they have made something that does not allow you to execute anything but still allows you to do anything you want.

这篇关于当Github收到更新时,将其推送到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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