How to Migrate Projects from TFS to Git
We’re using TFS (Team Foundation Server) in the company, and also using TFVC (Team Foundation Version Control) as a version control system for software projects. After a while, we decided to use the git version control system. We found a tool to migrate existing projects in TFVC to the Git.
Installing
You can install the tool (git-tfs) using Chocolatey. If you don’t have Chocolatey, you can install using this PowerShell command:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
After that, you need to re-open PowerShell window to run Chocolatey commands. Then, run this command to install git-tfs tool:
cinst GitTfs
Use git-tfs
Find a TFS repository path to clone:
git tfs list-remote-branches http://tfs:8080/tfs/DefaultCollection
NOTE: If your branch is not listed here, perhaps you should convert the containing folder to a branch in TFS.
Cloning a repository
# clone the whole repository (wait for a while...)
git tfs clone http://tfs:8080/tfs/DefaultCollection $/some_project --branches=all
Wait for git-tfs to pull your history. After completing the process, add a .gitignore file for all branches.
Clean old TFS files
Then run this command:
git rm -r --cached .
This removes everything from the index, then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"