If you want to migrate a full TFS collection, support is built-in. But what if you want to migrate a specific project but want to keep the source code history?
I blogged about a solution I used before by using Git as a way to move code between 2 TFS Version Control repositories. (Here is the link in case you cannot find it: http://bartwullems.blogspot.be/2015/05/team-foundation-server-how-to-migrate.html). I used this approach multiple teams with great success.
However some people who tried to do the same thing complained that the approach I described didn’t work when you have multiple branches. So time to solve this and add the misssing steps required to migratie multiple branches:
- Extract the old TFS project including all branches with the git-tfs tool:
- git-tfs clone --with-branches http://oldtfs:8080/tfs/DefaultCollection $/BranchingDemo/Main
- Open the .config file inside the .git folder and add a new remote:
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
autocrlf = false
ignore-branches = False
touch = 1
repository = $/BranchingDemo/Main
repository = $/BranchingDemo/Development/Feature1
repository = $/BranchingDemo/Development/Feature2
repository = $/BranchingDemo/Releases/Release 1
repository = $/NewRepository/DevFeature1
- Initialize the remote
- git-tfs branch –i BranchingDemo
- This disconnects the branch from the current remote and connect it to the new TFS server
- Switch between all branches and execute the following commands:
- git checkout "branchname"
- git tfs branch $/TargetProject/TargetBranch --comment="branch X"