Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created June 20, 2016 21:15
Show Gist options
  • Save adamdriscoll/8f9d1fef0e79f0dc4d1b534fe636b1be to your computer and use it in GitHub Desktop.
Save adamdriscoll/8f9d1fef0e79f0dc4d1b534fe636b1be to your computer and use it in GitHub Desktop.
Converts a TFVC repo to Git and creates the necessary Git repo in VSTS and uploads the Git repo
#This uses git-tfs and the PowerShell VSTS module
function ConvertTo-GitRepository {
param($Name, $Folder, $VstsUser, $VstsToken, $VstsAccountName, $VstsProjectName)
git tfs clone https://$VstsAccountName.visualstudio.com/defaultcollection $/$VstsProjectName/$Folder --branches=none
Push-Location (Split-Path $Folder -Leaf)
$ProjectId = Get-VstsProject -AccountName $VstsAccountName -User $VstsUser -Token $VstsToken | Where Name -eq $VstsProjectName | Select -Expand Id
New-VstsGitRepository -AccountName $VstsAccountName -User $VstsUser -Token $VstsToken -RepositoryName $Name -ProjectId $ProjectId | Out-Null
git checkout -b develop
git remote add origin https://$VstsAccountName.visualstudio.com/DefaultCollection/$VstsProjectName/_git/$Name
git push --all origin
git tfs cleanup
Pop-Location
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment