如何将TFVC仓库从一个VSTS实例迁移至另一个VSTS实例
Alright, let's figure out how to migrate your TFVC repo from one Azure DevOps Services (formerly VSTS) instance to another—keeping all your source code and full history intact, no work items involved. I get it, most guides either focus on on-prem TFS or converting to Git, so here are the practical, reliable methods tailored exactly to your TFVC-to-TFVC scenario:
This is the go-to tool for cross-instance Azure DevOps migrations, and it fully supports TFVC-to-TFVC history migration. It handles the heavy lifting of transferring all your changesets seamlessly.
Step 1: Install the tool
Open PowerShell as an administrator and run:Install-Module -Name AzureDevOpsMigrationToolsIf you prefer not to use PowerShell modules, you can grab the latest release package directly from the tool's official repo.
Step 2: Configure your migration settings
Generate a starter config file with:Export-MigrationToolConfig -ConfigFile .\tfvc-migration.jsonOpen the
tfvc-migration.jsonfile and update these key sections:- Under
Source, setCollectionUrito your source VSTS instance (e.g.,https://source.visualstudio.com/DefaultCollection) andProjectNameto your source project. - Under
Target, setCollectionUrito your destination VSTS instance (e.g.,https://destination.visualstudio.com/DefaultCollection) andProjectNameto your target project. - Find the
TfvcMigrationProcessorin theProcessorsarray, then setSourcePath(the TFVC path you want to migrate, like$/SourceProject/Main) andTargetPath(the empty path in your target repo, like$/DestProject/Main). Make sure the target path doesn't exist yet—the tool will create it automatically.
- Under
Step 3: Run the migration
Execute the migration with:Invoke-Migration -ConfigFile .\tfvc-migration.jsonThe tool will walk through every changeset from your source repo and replicate it to the target. Keep an eye on the PowerShell output for progress updates—this might take a while depending on the size of your repo and number of changesets.
If your TFVC repo is small and you don't mind a bit of manual work, this method works—but note that it won't preserve full changeset history (it'll push all files as a single initial check-in). Only use this if you don't need to retain individual changeset details:
Step 1: Clone the source repo locally
Use the TF command line tool (included with Visual Studio or the standalone TFS SDK) to clone the full source:tf clone https://source.visualstudio.com/DefaultCollection/SourceProject $/SourceProject/Main C:\LocalTFVCCopy /allThe
/allflag pulls all file versions, not just the latest.Step 2: Set up the target repo
In your destination VSTS instance, create a new project (or use an existing one) and ensure TFVC is enabled (it's on by default, but double-check in Project Settings > Repos). Create an empty root path for your migrated code (e.g.,$/DestProject/Main).Step 3: Push to the target
Create a new workspace linked to the destination instance:tf workspace /new /collection:https://destination.visualstudio.com/DefaultCollection DestWorkspaceMap your local clone to the target TFVC path:
tf workfold /map $/DestProject/Main C:\LocalTFVCCopyFinally, check in all files:
tf checkin /recursive /comment:"Initial migration from source VSTS instance"
- Backup first: Take a snapshot of your source repo before starting—better safe than sorry if something goes wrong.
- Lock source branches: If possible, lock the source TFVC branches during migration to prevent new changes from being added mid-process (avoids conflicts and missing history).
- Validate post-migration: After the migration finishes, spot-check a few key changesets in the target repo to ensure all files and history match the source.
内容的提问来源于stack exchange,提问作者Jason Butler

