Some time ago we were trying to migrate our code from TFS 2008 to the hosted TFS (http://tfs.visualstudio.com) using TFS Integration tool - http://tfsintegration.codeplex.com/. After a few failed attempts we decided not to migrate the history but only the latest version of code and keep the TFS 2008 for historical reference. Although the tool wasn’t properly tested with hosted TFS it worked in some cases. I managed to migrate a few folders but not the entire project. Our project has a complex tree structure and keeps the history since 2008. Also some of the branches were deleted during the time. Because of all of this the migration was a nightmare.
The migration was postponed due to other tasks and the good things happen during this time – Microsoft announced Git support in TFS, in hosted TFS as well. Hosted TFS had Git implemented for some time already but the option wasn’t enabled except for a few people including MVPs.
If you need to get your TFS source into Git first of all you need to get it from TFS into your local Git. For this purpose you’ll need either git-tfs or git-tf. After installing one of this, clone your TFS:
git tfs clone http://[YourTFSserver]:8080/tfs/DefaultCollection $[FolderOrProjectName]
Here we run into troubles as we were given the following error:
TF50605: There was an error looking up the SID for [SOME USER NAME]
The error was related to a domain user who left the company some time ago. Using the help from this web site: http://davehope.co.uk/Blog/deleting-the-tfs-workspace-for-a-missing-account-fails-tf50605/ we managed to delete the workspace linked to this user but it didn’t fix the issue.
When you clone the TFS project the command line will display the changeset it’s cloning, something like:
Which means the changeset 1250. We searched this changeset using Team Explorer in VS and we found out that the changeset is assigned to the same user with the workspace issue.
The only way to reassign this changeset to a different user is to update your TFS database.
Run this to find the owner if:
SELECT IdentityId FROM tbl_Identity WHERE (DisplayName LIKE 'USER NAME')
Now when you have the IdentityId you can find all the changesets made by this user:
SELECT * FROM tbl_ChangeSet WHERE ownerid = [OWNERID]
A simple update will reasign the changesets to another user:
UPDATE tbl_ChangeSet SET ownerid = [IDENTITYID OF ANOTHER USER], committerid=[IDENTITY ID OF ANOTHER USER] WHERE ownerid = [IDENTITY ID OF THE OLD USER]
After this update we clone the project again and after about 8 hours the project was cloned into local Git.
The next step is to push the source to the Git repository. Some steps, like removing TFS binding before pushing should be done. This article explain everything you need to now: http://devlicio.us/blogs/derik_whittaker/archive/2012/11/07/moving-from-tfs-to-github-what-we-did.aspx
If you want to use git from Visual Studio you’ll need to install the CTP for Visual Studio Update 2: http://blogs.msdn.com/b/visualstudioalm/archive/2013/02/11/february-ctp-for-visual-studio-update-2.aspx and Visual Studio Tools for Git: http://visualstudiogallery.msdn.microsoft.com/abafc7d6-dcaa-40f4-8a5e-d6724bdb980c