git 如何将 gitlab 与 github 同步
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32762024/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to sync gitlab with github
提问by mdekkers
I have several developers working on a local Gitlab instance. The client requires that their Github repo is kept updated. So our Gitlab repo should push any commits directly to Github. Any commits to Github should likewise be pulled into Gitlab.
我有几个开发人员在本地 Gitlab 实例上工作。客户要求他们的 Github 存储库保持更新。因此,我们的 Gitlab 存储库应该将任何提交直接推送到 Github。对 Github 的任何提交同样应该被拉入 Gitlab。
I could do the first part (dev --> gitlab --> github) with jenkins or something, but am stuck on the reverse. Our Gitlab and Jenkins run inside our firewall.
我可以用 jenkins 或其他东西做第一部分(dev --> gitlab --> github),但我被困在相反的地方。我们的 Gitlab 和 Jenkins 在我们的防火墙内运行。
Any hints or pointers (or drop in solutions!) would be very appreciated.
任何提示或指针(或解决方案!)将不胜感激。
回答by mlncn
It's only in the enterprise edition and on GitLab.com, butGitLab has introduced this feature directly, without any workarounds.
只有企业版和GitLab.com上才有,但是GitLab直接引入了这个功能,没有任何变通办法。
They've documented pulling from a remote repository.
他们已经记录了从远程存储库中提取的内容。
It's in the same section of configuration that you can push, too:
它也位于您可以推送的配置的同一部分:
- From within a project use the gear icon to select Mirror Repository
- Scroll down to Push to a remote repository
- Checkmark Remote mirror repository: Automatically update the remote mirror's branches, tags, and commits from this repository every hour.
- Enter the repository you want to update; for GitHub you can include your username and password in the URL, like so:
https://yourgithubusername:[email protected]/agaric/guts_discuss_resource.git
- 在项目中使用齿轮图标选择镜像存储库
- 向下滚动到推送到远程存储库
- 勾选远程镜像仓库:每小时自动从这个仓库更新远程镜像的分支、标签和提交。
- 输入要更新的仓库;对于 GitHub,您可以在 URL 中包含您的用户名和密码,如下所示:
https://yourgithubusername:[email protected]/agaric/guts_discuss_resource.git
Note that I haven't tried it, but you should be able to push to and pull from the same repository. It's working great for me pulling from a remote repository (drupal.org), and pushing to a different remote repository (gitlab.com).
请注意,我还没有尝试过,但您应该能够从同一个存储库推送和拉取。它非常适合我从远程存储库 (drupal.org) 中提取并推送到不同的远程存储库 (gitlab.com)。
回答by rugk
For syncing from GitHub to GitLab you could use the Webhooksto send a notification to your site and possibly manage this somehow (although I don't know if GitLab supports this out of the box).
为了从 GitHub 同步到 GitLab,您可以使用Webhooks向您的站点发送通知,并可能以某种方式进行管理(尽管我不知道 GitLab 是否支持开箱即用)。
And with a bit more implementation you could (theoretically) use the GitHub API.
通过更多的实现,您可以(理论上)使用 GitHub API。
I also found a small scriptnamed "simple (and dirty) sync between redmine issues and gitlab issues" which should do at least this.
我还发现了一个名为“redmine 问题和 gitlab 问题之间的简单(和脏)同步”的小脚本,它至少应该这样做。
回答by Garo
The answers of rugk and mlncn are outdated.
rugk 和 mlncn 的回答已经过时了。
The correct procedure is now described in this part of the gitlab docs.
现在在 gitlab 文档的这一部分中描述了正确的过程。