How to move your source code from TFS VCS to TFS Git or GitHub

source-control Nov 5, 2016

There's an excellent cross platform command line tool available called Git-TF. In a nutshell, it will let you clone an existing TFS managed project and initialize a local git repository. You can then hook itself to a remote Git repository (Gothub, Bitbucket etc.) and push the code along with all the commit / checkin history. I just moved one of my projects from TFS VCS to TFS Git in less than 30min in Mac running macOs.


Download this tool from Codeplex or Microsoft Download centre

macOS or Linux

Install homebrew, if you don't already have it.

ruby -e "$(curl -fsSL" < /dev/null 2> /dev/null

then use brew to install Git-TF

brew install git-tf

You will need Java runtime to run this tool. Please refer to the codeplex instruction if you have any trouble getting the tool installed. Honestly, if you can't get this tool working, then probably this article isn't what you are looking for.

To check if Git-TF has been installed properly, type git-tf in the terminal and hope than you don't see any error.

Cloning TFS VCS code as Git repository

Now you need to create a local clone of the original Team Project thanks to tf-git, just open a Git Bash console in a folder of your choice and type the command

git-tf clone –-deep $/MyTFSProject

Pay attention to use the –deep option to clone all check-ins of the original TFS repository, you now will be prompted for credentials and the clone operation will begin. I strongly suggest you to Enable Alternate Credentials to connect to your TFS so you can use a standard username/password combination to connect to your TFS Account. Now you can move into the new folder that will have the same name of your TFS Project and you should see all your original check-ins cloned in a local git repository.

At this point, the cloned project is essentially a Git repository without any remote origin attached to it. Create a new Git repository in TFS or Github and use the standard git command to add an origin to this cloned repository.

git remote add origin

Finally, Push the entire repository including the commit history migrated from TFS VCS Checkins

git push -u origin --all

Mohammad Mustakim Ali

I'm a Software Engineer living in London, UK. My passion is to make *very fast* software with great user experience and I have just got little better on this than I was yesterday.