How to migrate your projects from TFS to Git

Posted 30 July 2015 12:00 AM by Sergio Gisbert Ribes, Web Developer @ ClearPeople

Here at ClearPeople, we have decided recently to move all our source code projects from TFS 2010 on premise to Visual Studio Online. At the same time, we are reviewing and updating our source control workflow, so we decided to switch to Git as our Version Control System for all the new and already existing projects.

So we started an internal project called “Code migration from TFS TFVC to VSO Git”.

We’ll be focusing mostly on the code migration, as keeping the projects history was a key goal for the migration. 

Regarding all the work items and relationships between them, there is some additional information out there, like, but we finally decided to focus mainly on code, as moving the work items was not working in our scenario, where we have some custom templates for the TFS processes workflows.

As a starting point, we used the recommendations from, and based on them, we got a nice batch script that allowed us to move smoothly all our projects to VSO.

1.2 Prerequisites

  1. Install Git-Tfs tool:, and make sure it’s in the PATH
  2. Only branches can be migrated to Git, so we’d need to do different actions in the target project in TFS if needed

1.3 Batch file

Our batch file looks like this:


set localRepo=http://<local_tfs_url>:8080/tfs/DefaultCollection
set remote=https://<vso_account>

if -%1-==-- echo TFS Project not provided & GOTO usage
if -%2-==-- echo Local destination folder not provided & GOTO usage
if -%3-==-- echo Remote Project name not provided & GOTO usage
if -%4-==-- echo Remote repository name not provided & GOTO usage
GOTO continue

echo Usage: git-migrate [TFS Repo] [Destination Folder] [Remote Project] [Remote Repo]
exit /b

set repo=%1
set folder=%2
set remoteProject=%3
set remoteRepo=%4

setlocal EnableDelayedExpansion
set remoteProject=!remoteProject:"=!
set remoteRepo=!remoteRepo:"=!
setlocal DisableDelayedExpansion

echo Migration TFS project "%repo%" to VS Online project "%remoteProject%" into repo "%remoteRepo%"

setlocal EnableDelayedExpansion
set remoteProject=!remoteProject: =%%20!
set remoteProject=!remoteProject:"=!
set remoteRepo=!remoteRepo: =%%20!
set remoteRepo=!remoteRepo:"=!
setlocal DisableDelayedExpansion

git tfs clone %localRepo% %repo% %folder%
cd %folder%
git remote add origin "%remote%/%remoteProject%/_git/%remoteRepo%"

@ECHO ONgit push -u origin –all

Make sure you edit localRepo and remote variables and set your own urls and save it to a bat file, like git-migrate.bat.

1.3.1 Batch file usage

The usage of the file will be like this:

C:\Git>git-migrate.bat <local tfs project> <local folder> <VSO Project Name> <VSO Git Repo name>


  • <local tfs project>: is the name of the local project on TFS. Be careful with the spaces in the names, to use quotes if needed, like $"/tfs project name/src".
  • <local folder>: This is the local folder where the project will be cloned from TFS.
  • <VSO Project Name>: The project name in VSO
  • <VSO Git Repo name>: The repository name in VSO. It’s usually the same name as the project, but with Git, you can have several code repositories in the same project, so we can specify it.

For example, providing a local TFS project called $"/tfs project name/src", we’ll save it locally to folder "C:\Git\Website", and then, push it to the repository "VSO src" in the project "VSO Project", like this:

C:\Git>git-migrate.bat $"/tfs project name/src" "Website" "VSO Project" "VSO src"

1.4 Handling user authentication

During the “push” process, you will be asked for your credentials on VSO, and it may happen that you email cannot login successfully. To fix it, you need to enable alternate credentials to your account in VSO. You can do it following these steps:

1. Login to http://<vso_account>
2. Click on “My profile” link 

3. On the Credentials tab, choose “Enable alternate credentials”

4. Set secondary username (without “@”) and a password, and save changes

5. Use this new alternate credentials when you’re asked to login to VSO during the push process.


Add your comment





intranet Modern SharePoint teamwork employee engagement digital workspace SharePoint JavaScript Windows Azure Digital Transformation staff satisfaction productivity Microsoft Teams Office 365 Yammer cms content management system agile GDPR Microsoft Graph collaboration Microsoft sharepoint 2016 upgrade migration SharePoint Online 2016 Tech Trends Digital Disruption Context marketing marketing SharePoint 2010 SharePoint 2013 TFS Git security kentico Analytics jquery QA Quality Assurance testing content management websites Sitecore sitecore marketplace sitecore module cloud Microsoft Cloud Storage digital strategy technical consulting sitecore modules Experience database Sitecore 7 Sitecore 8 support account management customer experience Data Storage cms integration front end front end development prototype Cloud Storage StorSimple Front-end Development Layout SharePoint 2013 colour palette UI design website design log viewer sitecore cms website Azure big data business-critical sharepoint accessibility android apple chrome clear people clearpeople debug emulator ios mobile testing opera resize adobe desktop flash ie10 internet explorer 10 metro windows 8 bcsp Advanced System Reporter reporting framework ControlMode form control master page placeholder publishing console SharePoint 2007 SharePoint error search search results search values software testing testing scenario audit content information architecture retention schedules PowerShell QuickLaunch scripts SharePoint server 2010 business solutions metalogix replication replicator storagepoint stena technet UK Technet picture library slideshow web part RTM released to manufacturing caml caml query MOSS 2007 query infopath