This document defines the steps to be followed to migrate source code from TFVC to TFS-Git repository along with change set history
Here the Source is TFVC repository
Here the Target is TFS GIT repository
Following are the Pre-Requisites for the migration:
- Chocolatey package manager
- GIT-TF tool
- GIT Repository in TFS
What is Chocolatey package manager?
Chocolatey is a package manager for Windows. It is used for quickly installing applications and tools that we need. It is built on the NuGet infrastructure currently using PowerShell.
Chocolatey is an interface that is designed to work with all aspects of managing Windows software using a packaging framework that understands both versioning and dependency requirements.
STEPS TO FOLLOW:
- Open Command Prompt as Administrator
- Install Chocolatey package manager by running the below command:
@powershell -NoProfile -ExecutionPolicy Bypass -Command “iex ((New-Object System.Net.WebClient).DownloadString(‘https://chocolatey.org/install.ps1’))” && SET “PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin”
- Install GIT-TF Tool by running the below command in the same command prompt that was used to install Chocolatey package manager
Choco install git-tf –y
Along with git-tf tool even GIT is installed
- Now change the path from C:\Windows\system32 to git-tf installed path (by default the GIT-TF would be installed in C:\ProgramData\chocolatey\lib\Git-TF\Tools\git-tf-22.214.171.12431219. Here git-tf-126.96.36.19931219 is git-tf tool version).
So in my case I changed the path from C:\Windows\system32 to C:\ProgramData\chocolatey\lib\Git-TF\Tools\git-tf-188.8.131.5231219
- After changing the path run the git-tf clone command as below:
Git-tf clone “http://TFS Server Name:Port/tfs/” “$/TeamProjectName” –deep
Note: –deep: Flag used to clone each TFS change-set for the specified path into the new Git repo
After running the clone command, you’ll have all the projects downloaded in your local machine from TFVC Team Project (Path would be the installed path of GIT-TF tool/Tools/Project Name)
- Now Open GIT Bash as Administrator from Search and change the path where TFVC project is downloaded
Note: GIT BASH is installed along with GIT-TF tool
- As soon as change the path, you’ll see a MASTER branch appear in the GIT Bash.
- Create a GIT repository in TFS
- You need to push this to the GIT repository on TFS.
Run the below command to first add the GIT repository and then push it to TFS server. (Here Master is the default branch which is created whenever you have a git repository)
Git remote add origin TFS server name:PortNumber/tfs/CollectionName/TeamProjectName/_git/GITRepositoryName
- Refresh the browser and open the GIT repository where you wanted the source code along with the changeset history to be migrated