Migrate Azure DevOps TFS to Git reserving history

Microsoft acquired GitHub, and every one have unlimited private repository. This reason alone make me want to move all my project and source code to GitHub.

1. A bit of history

In around 2012, developers don’t have much choices in where to store their code for free. Sure you can use GitHub, but it limit the number of private repository and number of collaborators. The obvious choice at that time was Visual Studio Online, or today Azure DevOps. The only source control system it’s provided is Team Foundation Server (TFS).

Today, 9.99 over 10 developers will choose git over tfs, and we need a way to migrate from TFS, with history, to git.

2. Required tools

Alternatively, you can install git-tf with Chocolatey:

choco install gittfs

3. Migration steps

3.1. Clone the TFS project

git-tfs clone https://your\_organization.visualstudio.com/ $/your_project_name

If your project name contain whitespace, just put the whole name in quote mark

git-tfs clone https://your\_organization.visualstudio.com/ “$/your project name”

This will clone the project to the folder you run the command

3.2. Add .gitignore

Now the project is like any other git project, with a .git folder. You should add a .gitignore file to prevent commit unwanted files.

A sample .gitinore file here: Visual Studio Git Ignore

3.3. Push code

The final step is to push code to your favorite git service.