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

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

问题描述

让 Github 自动将任何更新推送到远程服务器的设置是什么?

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

这对于在 Github 上维护代码库以及让网站运行该代码库非常有用.

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

  1. 我在自己的电脑上有我的仓库,这就是我工作的地方.

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

我在本地存储库上提交更改,并将它们推送到我的 Github 存储库.

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

我希望我的 Github 存储库将这些更改推送到我的远程服务器.

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

我一整天都在研究,使用钩子"听起来很合理.也许在 Github 上使用post-receive"挂钩,然后向我的远程服务器运行推送命令.

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.

有什么建议吗?

推荐答案

据我所知,github 不允许您定义真正的"钩子.像后接收.相反,他们为开发人员提供了一种叫做 webhook 的东西.您可以做的是,只要有推送到您的存储库,就向您指定的任何 URL 发出 Web 请求.

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.

所以你可以做的是:在你的远程 git 服务器上设置一个网络服务器并配置 github 以在接收后对其进行 http 调用.每当 github 通知你的远程服务器时,就从 github 拉取它.

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.

有关如何使用 webhooks 的信息,请参见此处:https://help.github.com/articles/post-receive-钩子

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

附言一个真正的钩子机制可能是 github 的一个安全漏洞,因为它允许你在他们的服务器上执行自定义代码.所以他们做了一些不允许你执行任何事情但仍然允许你做任何你想做的事情.

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天全站免登陆