TFS to Git - Time to flip the switch

  • 2 min read

Intro

I had an early exposure working with Git that dates back to my first programming job over at Minnesota State Lottery. Unfortunately, this was my first and last job that actually had Git as their primary source control system until recently. For the current project that we've been working so diligently on, we wanted to explore whether Git would be beneficial to us.

Over the years, Git managed to gain tremendous traction especially when GitHub launched and open source developers and even Microsoft started embracing the simplicity of Git source control system.

In this post, I won't go into details about the benefits of switching over to Git and how it can be beneficial to you and your team or more so your organization as there are plenty of resources out there that will shed some light on this subject.

Git-TFS to the rescue!

There is an open source project called Git-TFS (my huge thanks to all the contributors!) that simplifies the process of migration from TFS source control over to Git. One of the best thing about this project is that it is able to retain all the history when the migration takes place!

  1. First, let's head over to the project site and download the latest release - you can go to Releases (as shown below) and download an archive file that contains command-line based executable.

    git-tfs-release

  2. Clone existing TFS branch with history

    For the sake of simplicity and the fact that this project is still active, I am going to refer you to their latest documentation provided on their site rather than mention any other commands here. With that said, if you just wish to clone an existing TFS branch and also keep the history then use the simple command shown below:

    .\git-tfs.exe clone https://{tfs-site-name} $/{site-collection}/{branchName} {path-to-local-folder}/{your-project-name} --branches=auto
    

    When you run this command, please keep in mind that the process will take some time (~2-10 minutes) depending on the number of files and history it has to process.

    In the end, you will have a local git branch (located under the path you provided above) converted over to Git. Now, it's just a matter of checking in the local changes to remote Git repository!