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
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 }