Migrate code from TFVC to Azure Repos

Over the last few years organizations are moving closer to their customers in order to remain relevant and useful. This helps them understand their customer better which in turn allows them to serve their customers well. Moving closer to customers becomes effective with capability to deliver value quicker. This is what lead to organizations adopting devops best practices (among other like lean, agile etc).
Devops best practices are enabled by software development tools which allow an organization to be able to deliver value as frequently (more) and as quickly(fast) to end customers. One such tool that has become the de-facto standard of developers is git and its numerous hosting platforms like Github, Azure Repos (part of AzureDevops), bitbucket etc.
Newer organizations find it easy to setup their repos using git. But how does an organization using Microsoft TFS (TFVC) as their code repo harness the benefits of using git? How do they move their code from TFVC to git?

The most common (and to an extend logical) solution is to leave history behind in TFVC and move tip (latest changeset) to git and start creating history from that point on. But what if Azure Repos provides an option to move history (maximum up to 180 days back) from TFVC to Azure Repos?
I moved a few TFVC repositories to Azure Repos and came across a few interesting ideas on what can and what cannot be moved. All in all, I think it’s a good option to be aware of, if there arises a requirement to do so.
Step 1: Create an empty repository in Azure Devops
Make sure you do not add a Read Me or a git .ignore file because if you do so, your repo gets initiated and there is not an easy way to use the import functionality once the repo is initiated.
20. MTAR-Image1
Add them once code has been migrated from TFVC.
Step 2: Add some code
Once our repo is ready we are greeted by the customary welcome note of an empty repo.
Select the third option: import a repository
20. MTAR-Image2
Step 3: Git or TFVC
Under the import option we have a choice -Git or TFVC. Select TFVC
20. MTAR-Image3
Note: this path has to be a project hosted in TFS in the same collection.
The migrate history option allows to take a maximum of 180 days history from TFVC ->Azure Devops.
20. MTAR-Image4
Also note that one branch in TFVC is one repo. This means that if you have a parent folder and inside that three TFVC repos like Dev, Test and Release where Dev and Release are branched out of Test then you won’t be able to migrate that branch relationship (parent-child) into Git. Contents of only one branch will be consumed by one repo.
20. MTAR-Image5
I also noticed that Microsoft does not recommend taking history from TFVC but just the tip (latest changeset).
This transfer request took a few minutes and once it was done I could see history form TFC in Azure Repos. The first commit had a reference to the source of this repo in TFVC; the location from where it was imported among with the changeset# in the commit message. After that, the rest of the changesets of TFVC were converted to commit# with the same author, commit date and comment. I however did not find any work items being attached to the commits that were attached with the original changeset in TFVC.
20. MTAR-Image6
A few points to ponder:
-one branch in TFVC can be converted to one repo in Azure Repos
-attached work items of TFVC changesets do not carry over to commits of Azure Repos
-branch relationship in TFVC do not carry over to Azure Repos
-code in TFVC can continue to live side by side the migrated code to Azure Repos; development can continue in both repos (TFVC and Azure Repos) but these are not visible to each other -no relationship

On the overall this is a good feature for a project that has code (with history) in TFVC and wants to start using Azure Repos by migrating code with history.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s