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:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
autocrlf = false
[git-tfs]
ignore-branches = False
[tfs]
touch = 1
[tfs-remote "default"]
url = http://oldtfs:8080/tfs/DefaultCollection
repository = $/BranchingDemo/Main
[tfs-remote "Development/Feature1"]
url = http://oldtfs:8080/tfs/DefaultCollection
repository = $/BranchingDemo/Development/Feature1
[tfs-remote "Development/Feature2"]
url = https://oldtfs:8080/tfs/DefaultCollection
repository = $/BranchingDemo/Development/Feature2
[tfs-remote "Releases/Release1"]
url = http://oldtfs:8080/tfs/DefaultCollection
repository = $/BranchingDemo/Releases/Release 1
[tfs-remote "BranchingDemo"]
url = http://newtfs:8080/tfs/DefaultCollection
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"