Migrating version control TFVC for GIT
The SourceControl GIT is becoming the most popular and used tool in the world. This tool was developed in 2005 by Linus Torvalds to control the code of kernel of Linux and after has been incorporated in github it has grown much more.
Since 2013, Microsoft made available the option to choose between TFVC or GIT as SourceControl, but which one chooses? That choice provides the direction of how your code will be managed.
TFVC was born with the first version TFS to help in Source Control of code and thenceforth has been used. TFVC is a centralized version control easy to be used and maintain all in server except code gated locally where you get code from server (like snapshot) to local given choice which changeset you want to get, do code changes locally then check-in it at server again made available for everyone, of course we have a lot of other functionality as merge, shelve, history, gated check-in, check-in policies.
Git version control is a Distributed Version Control System (DVCS) where the differences is instead of get last version locally from server as TFVC do, in GIT you can “clone” all code locally could work offline and also still history locally then when you feel necessity to make available your changes for team you do a “push” in a remote branch, could be any branch you want to. This option helps a developer to create branches easily and merge between those branches. One important point is the learning curve of GIT and should be taken into consideration if your team is used to using TFVC.
installing with chocolaty:
https://chocolatey.org/install (see more details)
- Install chocolatey via powershell:
- choco install gittfs
- Prepare environment – First is necessary to prepare where you are going to clone the repository from tfvc. You can create a directory by graphic interface or by command line.
- Command line (using powershell)
- Go to directory created (using powershell)
- Before you start your migration using command line, it is necessary to create a repo in GIT were those branches will be migrate (using Azure DevOps Service):
- Open your project and go to “Repos”
- Choice option “new repository”
- Choice the name you want and don’t add readme or gitignore in this time
- After created a repo, copy the URLs provided, you going to use it
- Commands to see which branches are able to migrate (using powershell):
This will clone the branches that you specify for the repository has been created.
- Git tfs clone http://yourtfsurl/project $/branchpath . –branches=all
This will create a relation between your local repo and the repo has been created in Azure DevOps. This URL is provided after having created the repository.
- git remote add origin https://HeiderHengstmann@dev.azure.com/HeiderHengstmann/GFT/_git/MigratingVCtoGIT
This will copy the code that is locally to repo in azure DevOps
- git push -u origin –all
Using gittfs to migrate, you can choose the option to migrate all structure branches or only the “Main” and you can bring all history. You also have the option to migrate by graphic interface, where we are talking about Azure DevOps or TFS (above 2017), but you only will have the option to migrate one branch with 180 history days!
- Migrating using Graphic Interface:
- First at all, you need URL to clone, is same URL to clone a repo or tfvc for your local environment
- Then you can go to “repos” and choose the option to import.
At this moment you will choose which one is your repo you want to bring, specify the URL you took and the name of the repo will be created.
Is not possible to migrate a TFVC from another TFS using that option, to do so it is necessary to follow gittfs instruction.
References[Migrating from TFVC to Git]