How to synchronize VSTS and Github respositories when commits are made

后端 未结 2 1797
南笙
南笙 2020-11-29 00:40

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

This allows me to do my main development in VSTS

2条回答
  •  旧时难觅i
    2020-11-29 00:57

    For anyone wanna sync all branches from Github to VSTS by using powershell

    You need to create a repo in VSTS with the same name in Github first.

    Add a PowerShell process as the following script. It should work with any account and repo.

    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 }

提交回复
热议问题