【发布时间】:2016-04-23 17:20:22
【问题描述】:
我在 Visual Studio 团队服务中有一个存储库,我想与 github 存储库保持同步。
这允许我在 VSTS 中进行我的主要开发,当合并到 master 时,它将同步到 github,还允许其他人在 github 上贡献,当 Pull Requests 合并到 master 时,它会同步到 VSTS。
【问题讨论】:
标签: github azure-devops
我在 Visual Studio 团队服务中有一个存储库,我想与 github 存储库保持同步。
这允许我在 VSTS 中进行我的主要开发,当合并到 master 时,它将同步到 github,还允许其他人在 github 上贡献,当 Pull Requests 合并到 master 时,它会同步到 VSTS。
【问题讨论】:
标签: github azure-devops
首先在 VSTS 上创建一个使用应从 VSTS 同步的存储库的新构建:
两者中的最后一个需要来自 Github 的个人访问令牌。
在图像中,两个 CMD 任务都使用 GIT 工具和以下两个命令:
pull https://github.com/s-innovations/MessageProcessor.ServiceFabric.git master
和
push https://$(githubpersonaltoken)@github.com/s-innovations/MessageProcessor.ServiceFabric.git head:master
启用 CI 选项以触发构建运行,只要有东西提交给 master。
现在可以用另一种方式进行相同的操作,以相同的方式进行新构建,但将 url 更改为目标 Visual Studio 在线存储库。
请注意,在 vsts 上使用个人令牌时,url 的身份验证部分需要为 https://:token@,而在 github 上则为 https://token@。
push https://$(vstspersonaltoken)@sinnovations.visualstudio.com/DefaultCollection/S-Innovations%20MessageProcessor/_git/messageprocessor-service-fabric head:master
他们在 VSTS 上对其进行了更改,因此如果存在冒号,它将无法通过身份验证。以上描述已更新。
【讨论】:
fatal: Not a git repository (or any of the parent directories): . 在拉动步骤上。不知道该怎么做...
对于任何想要使用 powershell 将所有分支从 Github 同步到 VSTS 的人
你需要先在 VSTS 中创建一个在 Github 中同名的 repo。
添加一个 PowerShell 进程作为以下脚本。它应该适用于任何帐户和回购。
git branch -r | findstr /v "\->" | ForEach-Object {$br=$_.TrimStart(); git branch --track $br.TrimStart("origin/") $br}
$repoName = "$env:BUILD_REPOSITORY_NAME".split('/')[1]
$repoUri = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI".Substring(8)+ "_git/$repoName"
git remote add vsts "https://$env:SYSTEM_ACCESSTOKEN@$repoUri"
git branch -r | findstr /v "\->" | ForEach-Object { $br=$_.TrimStart(" origin/"); git push -u vsts $br }
【讨论】: