CodeBlog.xyz

Migrate from TFS to Git

September 8, 2023 | by Meir Achildiev

Migrate from TFS to Git

You can migrate from TFS to Git without losing history, although the process can be somewhat intricate. The migration process usually involves using a tool to map TFS changesets to Git commits. Here’s a step-by-step guide:

Pre-Requisites:

  1. Backup your TFS Repository: Always take a backup before doing any sort of migration.
  2. Install Git: Make sure Git is installed on your machine.
  3. Access to TFS: You should have sufficient permissions on TFS to read the repository.
  4. Git-TFS: Install Git-TFS, a set of command-line tools that allow you to work with TFS directly from Git.

Steps:

Using Git-TFS:

  • Clone the TFS Repository:
    Open a terminal and run the following command. This will clone the TFS repository and map each changeset to a Git commit.
git tfs clone http://tfs-server:8080/tfs/DefaultCollection $/Project/Path
  • Check the Log:
    Ensure that the history has been correctly imported.
git log
  • Remote Repository:
    Initialize a new Git repository where you want to push your code. This could be on GitHub, GitLab, etc.
git remote add origin <Remote Repository URL>
  • Push to Remote Repository:
    Push your code, along with its history, to the remote Git repository.
git push -u origin --all

Using TFS-Git built-in Tool (Azure DevOps):

Azure DevOps provides an easier migration path if you are using a more recent version of TFS that has this feature built-in. Follow the below steps:

  1. Navigate to your TFS Project: Open the Azure DevOps portal and navigate to the Repos section.
  2. Import Repository: Choose the “Import Repository” option.
  3. Select Source Type: Choose “TFVC” and provide the necessary path and credentials.
  4. Start Import: Click on “Import” to start the migration process.

Post-Migration Steps:

  1. Validation: Validate if the history and branches have been migrated correctly.
  2. Team Transition: Make sure the team transitions smoothly by setting up proper documentation and perhaps a training session on Git basics.

Pros and Cons of Migration:

Pros:

  • Gain all the advantages of Git, like better branching, collaboration, and distributed development.
  • Maintain history, branches, and tags.

Cons:

  • Time-consuming: It can be a lengthy process depending on the size and complexity of your TFS repository.
  • Learning Curve: Your team will need to adapt to Git if they are not already familiar with it.

RELATED POSTS

View all

view all