Git:从存储库自动拉取? [英] Git: auto pull from repository?

查看:36
本文介绍了Git:从存储库自动拉取?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以设置 git,使其侦听来自远程仓库的更新,并在发生变化时进行拉取?用例是我想使用 git 部署一个 web 应用程序(所以我得到了部署应用程序的版本控制)但想将中央"git repo 放在 Github 而不是 Web 服务器上(Github 的界面非常好).

Is there any way to set up git such that it listens for updates from a remote repo and will pull whenever something changes? The use case is I want to deploy a web app using git (so I get version control of the deployed application) but want to put the "central" git repo on Github rather than on the web server (Github's interface is just soooo nice).

有人用过这个吗?Heroku 是如何做到的?我的 Google-fu 没有给我任何相关结果.

Has anyone gotten this working? How does Heroku do it? My Google-fu is failing to give me any relevant results.

推荐答案

Git 有钩子",可以在其他动作之后执行的动作.您似乎正在寻找的是接收后挂钩".在 github 管理员中,您可以设置一个 post-receive url,每当有人推送到您的 repo 时,该 url 都会被命中(带有包含有关刚刚推送内容的数据的有效负载).

Git has "hooks", actions that can be executed after other actions. What you seem to be looking for is "post-receive hook". In the github admin, you can set up a post-receive url that will be hit (with a payload containing data about what was just pushed) everytime somebody pushes to your repo.

就其价值而言,我认为自动拉取不是一个好主意——如果将错误推送到您的分支怎么办?我会使用像 capistrano(或等效工具)这样的工具来处理这些事情.

For what it's worth, I don't think auto-pull is a good idea -- what if something wrong was pushed to your branch ? I'd use a tool like capistrano (or an equivalent) for such things.

这篇关于Git:从存储库自动拉取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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