Migrate from TFS to GIT “Visual Studio Online”


Recently our company passed to GIT.

My personal projects were stored on Visual Studio Online. All projects were created with Team Foundation Server (Default on visual studio online) source control but VS gives a possibility to create projects for GIT as well. To keep more visual project evaluation (branches, tags, commits etc.) which is not really possible on TFS I have moved TFS projects to GIT under VS Online. In this way my personal and professional projects will be managed in one place (SourceTree) and in one single way.

To migrate your project here are some useful steps how to do this (original article can be found here):

Install Chocolatey to be able to download git-tfs pacakge. This project gives a better and easiest way to do that. To install this project:

  • Run CMD as administrator.
  • Execute following command:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command “iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1 ‘))” && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

You can also start this directly from PowerShel using following command:

iex ((new-object net.webclient).DownloadString(‘https://chocolatey.org/install.ps1’))


This will install project to your user folder: C:\Users\<YourUser>\chocolatey
or in


Once this is installed you can download and install git-tfs package. Run following command to do this:

cinst gittfs


This will install package git-tfs to C:\tools\gittfs folder. Navigate to this folder in CMD.

git-tfs list-remote-branches https://tfs.contoso.com/tfs/DefaultCollection


Note default branch of the project which is marked by [*]. This should be similar to /Project/BranchPath.

Now you can clone this TFS project to you local GIT repo:

git-tfs clone https://tfs.contoso.com/tfs/DefaultCollection $/Project/Branch [Directory path] –branches=all


Attantion, you should specify –branches=all to export all merges of your branches.



  • $/Project/Branch – Default project’s master branch path which you have found when listed all branches.
  • [Directory path] is a path where you local REPO will be stored.


Note, before proceed to next operations, please, do a backup of all you projects TFS stored on local disk!


In this step we will recreate new project on VS Online based on GIT source control instead of TFS. To do this:

  • Navigate to you VS Online account.
  • Go to setting by clicking on settings icon (Figure 1).
Migrate-VSO-GIT (Figure 1)
Migrate-VSO-GIT (Figure 1)
  • Go to default collection to list all your projects (Figure 2)
Migrate-VSO-GIT (Figure 2)
Migrate-VSO-GIT (Figure 2)
  • In context menu of the project select “Delete” (Figure 3)
Migrate-VSO-GIT (Figure 3)
Migrate-VSO-GIT (Figure 3)
  • Read and confirm delete (Figure 4)
Migrate-VSO-GIT (Figure 4)
Migrate-VSO-GIT (Figure 4)
  • Wait while removed (Figure 5)
Migrate-VSO-GIT (Figure 5)
Migrate-VSO-GIT (Figure 5)
  • Now project is removed (Figure 6)
Migrate-VSO-GIT (Figure 6)
Migrate-VSO-GIT (Figure 6)
  • Now create new project (out of scope in this artcle)
Do not forget to change Source Control Version from TFS (which is default one) to GIT.


  • Navigate to “Code” tab in VSO and note URL to clone.
  • Navigate in CMD to your local repo and execute following command:
git remote add origin [URL to clone]


This will set the origin (the remote repository address) to point to our git repository in VSO.


If your repository has a BUG there is one hour timeout when push to VSO. Check original article for solution or check on internet.


Now we just need to push changes to VSO by using following command:

git push -u origin master


When you have several branches:

  • Do same above push command by specifying the branch to which to push  instead of “master”.


Andrew Adamich


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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: