You want to be like all the cool kids and use Git? Me too. Have a ton of source code history you don’t want to lose? Me too.

The steps below will create a Git repository from your Team Foundation Version Control source code including all historical versions along with their comments.

Note: This is for Microsoft’s Visual Studio Online cloud offering (formerly known as Team Foundation Service), not to be confused with their standalone Team Foundation Server (TFS) product.

Setup

  • Enable basic authentication in Visual Studio Online (click on your name, and then My Profile)
  • Download git-tf from Microsoft & extract
  • If you don’t have it already, download Java & make sure you have your PATH variables setup properly.
  • You’ll need to add the git-tf folder to your PATH as well. You can also do it at run-time if you want: C:>set PATH=%PATH%;C:\\your-path-to-the-extracted-git-tf-folder

Now CD into the root folder where you want to store your source code (I keep mine in C:\Code). Note: git-tf will create a folder inside this folder.

Run the command git-tf clone https://your-tfs-instance.visualstudio.com/ $/YourProjectName --deep (that’s: dash dash deep) The –deep is what tells it to pull in historical versions.

You should get prompted for credentials:

Connecting to TFS… Username: [email protected] Password: the-password-you-created-when-you-enabled-basic-authentication

Then you’ll see it whip through all your filenames with a percentage. This will take a long time if you have a large project and/or a lot of history:

Cloning $/YourProjectName into C:CodeYourProjectName: 100%, done. Cloned changeset some-number as some-number

Once this is done, you can open the Git repo using your tool of choice and see ALL history. Just push it to your remote repository, and you’re all set!