Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

Convert your TFVC Source Control to Git: The #1 Most Hidden Feature in all of Azure DevOps


Do you have an Azure DevOps TFVC source control repository that you wish you could convert or import to Git? Did you know that Azure DevOps and Team Foundation Server already can do that? We all know that there are lots of features in Azure DevOps Server and Azure DevOps Services. Lots. Like lots and lots. And insane number of features. But the convert / import TFVC to Git feature is well-hidden.

Yah. Lemme show you.

Why do I care about version control?

Azure DevOps has been around for a while. It used to be named Team Foundation Server (TFS) and TFS got started back in 2005. So when you think about it, Azure DevOps has been around for 15+ years. That’s a long time in technology. Back then, the world was mostly using centralized version control systems.

When you’re working with a team, you’ve got a lot of people all making changes to your code. If you don’t have any version control system, then whomever makes a change wins…until the next person makes a change and then that person wins. If those people aren’t paying attention, it’s profoundly easy to destroy each others’ changes and turn your source code into a pile of trash. That’s why we have a version control system. Version control has the smarts to make sure that we don’t just stomp all over everyone else’s changes.

Centralized Version Control vs. Distributed Version Control

There are two major ways to implement version control: Centralized or Distributed. Back in 2005 when Team Foundation Server (aka. Azure DevOps) got started, the world was using centralized version control. In a centralized version control system, you rely on a central server to track all the changes, adjudicate any conflicts, and do the work of integration.

BTW, there ain’t nothin’ wrong with centralized version control. It works great. It’s easy to understand. Branching can be a little difficult sometimes…but branching is always hard. (Well, actually, branching is easy. It’s the merge that gets you.) Centralized is fine. But the software world has moved to Git in a big way.

Git is a distributed version control system (DVCS). Git is arguably the most popular distributed version control system out there. It’s what all the cool kids use.

In a DVCS like Git, there isn’t that one central server that is the guardian of truth. Sure, in git you can have a central server (aka. a git “remote”) but it’s not responsible for nearly the same amount of stuff as the central server in a centralized version control system.

In Git, everybody has a full copy of the entire repository — and that includes every single change that has ever happened since the beginning of time. This lets you do a lot of interesting things (that I’m not going to get in to right now).

Developers (me included) prefer to use Git now.

So what happens if you’ve got all your Azure DevOps stuff in a centralized version control system like Team Foundation Version Control (TFVC)?

Well, that’s where that awesome hidden feature comes in.

Convert your Azure DevOps TFVC version control to Git

Let’s say that you’ve got an existing project in Azure DevOps and you want to convert it’s TFVC repository to Git. The first thing you’ll do is open your project in a browser and navigate to Repos and then go to the Files view.

The history tag for an existing TFVC repository in Azure DevOps 2020.
The History tab on an existing TFVC repository

I think that there are three reasons why this feature is “hidden”: 1) It’s buried in the repositories menu, 2) it’s hidden behind a link that has a really confusing name and 3) even if you manage to bring up the right dialog, the feature is buried under a strangely named drop down control.

  • At the top of the version control window, click the repositories drop down and then choose Import repository
To start converting your Azure DevOps TFVC repository to Git, go to the repositories menu and choose Import repository
Click the Repositories menu and choose Import repository

You should now see the Import a Git repository dialog. I don’t know about you but when I look at this dialog I immediately think “well, this isn’t right…I want to convert a TFVC repository”. Trust me. This is where we want to be. Confusing, isn’t it?

The import git repository dialog is the first step of the conversion process
The Import a Git repository dialog

Well, if you change the Repository type to TFVC, it starts to make a lot more sense.

  • From the Repository type drop down, choose TFVC
Change the repository type from Git to TFVC before importing
On the Import a Git repository dialog, change the Repository type to be TFVC

As soon as you change that repository type drop down to say TFVC, the dialog title changes to be Import from TFVC. It’s not a perfect description…but it’s better.

Before we start the import, a little advice.

You Probably Shouldn’t Import Your Whole Repository

When you import from TFVC to Git, you’re probably NOT going to want to import your entire TFVC repository. My recommendation is to import just the code for a single solution (*.sln) or a couple of related solutions. This means that you need to figure out the folder path for the folder you want to import.

In this guide, I’m just going to import the code for my Demo solution. I need the path for this folder. I can either just type the path or I can copy it to the clipboard. Doing this using the clipboard will save you typing and make sure that you don’t make any weird mistakes.

  • In the path bar, click on the name of your folder
Copy the path to the TFVC folder that you want to import by clicking on the folder name
The folder path bar for my Demo solution

Once you click on that folder name, the full path is revealed to you.

  • Copy the path value to your clipboard
Copy the fully-qualified TFVC folder path to your clipboard.  You'll need this later when you start the import.
The TFVC path to your folder

Import your TFVC Repository to Git

Let’s actually do the import. As part of this process, it’s going to create a new Git repository off of your Azure DevOps Team Project and then (optionally) import version control history into the new Git repository.

  • At the top of the version control window, click the repositories drop down and then choose Import repository to bring up the import dialog
  • Set Repository type to TFVC
  • Set Path value to the folder in TFVC that you want to import (for example, $/MyTfvcProject/Main)
  • Check the Migrate History checkbox
  • In the Days box, enter the number of days of history to import. (NOTE: in order to keep your repository size down, I’d recommend keeping this to 180 days or less)
  • In the Name box, enter the name for your new Git repository (for example, “Demo Project”)
  • Click the Import button to begin the conversion
In the Import from TFVC dialog, you can enter the options for the stuff you want to import to Git
Set the values for the TFVC migration to Git and click Import

The import process should start running.

The TFVC to Git import conversion process is running.
The import process has started

After a few minutes, the import should complete.

The TFVC to Git import conversion process has completed.
The import has completed

You should now be on your new Git repository.

Here's your the new Git repository that was imported from TFVC.

Your TFVC to Git conversion is complete.

Summary

Converting your existing Azure DevOps TFVC source control repositories over to Git is simply a matter of running the (hidden) conversion process. Once you figure out where that conversion dialog is hidden, moving from TFVC to Git is only a few minutes away.

Hope this helped.

-Ben

— Getting your code imported from TFVC to Git is only the first part. Do you want some help getting good at using Git on your team? What about tips on Git branching? Or perhaps some help hooking your automated builds and releases up to your Git pull request / code review process? Is git branching messing up your Scrum process? We can help. Drop us a line at info@benday.com.

SUBSCRIBE TO THE BLOG


2 responses to “Convert your TFVC Source Control to Git: The #1 Most Hidden Feature in all of Azure DevOps”

  1. […] Convert your TFVC Source Control to Git: The #1 Most Hidden Feature in all of Azure DevOpsIf you’ve been wanting to move from TFVC to Git, Ben has you covered. […]

  2. […] Convert your TFVC Source Control to Git: The #1 Most Hidden Feature in all of Azure DevOpsIf you’ve been wanting to move from TFVC to Git, Ben has you covered. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.