提交时如何同步 VSTS 和 Github 存储库 [英] How to synchronize VSTS and Github respositories when commits are made

查看:27
本文介绍了提交时如何同步 VSTS 和 Github 存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Visual Studio 团队服务中有一个存储库,我希望与 github 存储库保持同步.

I have a repository in visual studio team services that I would like to keep synchronized with a github repository.

这让我可以在 VSTS 中进行我的主要开发,当合并到 master 时,它会同步到 github,也允许其他人在 github 上做出贡献,当有 Pull Requests 合并到 master 时,它会同步到 VSTS.

This allows me to do my main development in VSTS and when merging into master it will be synced to github and also allow others to contribute on github and when there Pull Requests are merged into master its synced to VSTS.

推荐答案

首先在 VSTS 上创建一个使用应该从 VSTS 同步的存储库的新版本:

First create a new build on VSTS that is using the repository that should be synced from VSTS:

添加两个将运行一些 git 命令的 CMD 任务.

add two CMD tasks that will run some git commands.

两者中的最后一个需要来自 Github 的个人访问令牌.

where the last of the two needs a personal access token from Github.

在图像中,两个 CMD 任务都使用 GIT 工具和以下两个命令:

In the images both CMD tasks uses the GIT tool and the following two commands:

pull https://github.com/s-innovations/MessageProcessor.ServiceFabric.git master

push https://$(githubpersonaltoken)@github.com/s-innovations/MessageProcessor.ServiceFabric.git head:master

启用 CI 选项以在将某些内容提交给 master 时触发构建运行.

Enable the CI option to trigger the build to run whenever something is commited to master.

现在可以用另一种方式来做同样的事情,其中​​以相同的方式构建新版本,但将 url 更改为目标 V​​isual Studio 在线存储库.

Now the same can be done the other way, where a new build is made the same way but with the urls changed to target visual studio online repository.

请注意,在 vsts 上使用个人令牌时,url 的身份验证部分需要是 https://:token@ 在 github 上它只是 https://token@.

Do note that when using personal tokens on vsts the authentication part of the url needs to be https://:token@ and on github its just https://token@.

push https://$(vstspersonaltoken)@sinnovations.visualstudio.com/DefaultCollection/S-Innovations%20MessageProcessor/_git/messageprocessor-service-fabric head:master

2017 年 8 月更新

他们在 VSTS 中更改了它,例如,如果存在冒号,则身份验证将失败.以上描述已更新.

Update AUG 2017

They changed it at VSTS, such if the colon is present it will fail auth. The above description have been updated.

这篇关于提交时如何同步 VSTS 和 Github 存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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