Azure DevOps Server 2019 Cookbook(Second Edition)
上QQ阅读APP看书,第一时间看更新

How to do it...

In this section we'll cover the steps for migrating the code from TFVC to git with history:

  1. Launch the command line and run the following command; --deep is used to extract the entire history from this repository. This operation may take longer to complete, depending on the size and depth of history of the source repository:
git-tf clone --deep http://myOldAzure DevOps ServerServer/Azure DevOps Server/DefaultCollection $/OldTeamProject/App2BeMigrated C:\migrated\App2BeMigrated
  1. In the command line, change the directory to C:\migrated\App2BeMigrated and run the following command. This will clean the Git metadata from the commit messages:
git filter-branch -f --msg-filter "sed 's/^git-Azure DevOps Server-id:.*;C\([0-9]*\)$/Changeset:\1/g'" -- --all
  1. Delete the .git/refs/original folder in C:\migrated\App2BeMigrated to delete the old branches as they are not needed anymore. To publish the local migrated Git repository in Azure DevOps Server, you'll need to create a new Git repository in Azure DevOps Server. To do this, navigate to the PartsUnlimited team project in the team portal and create a new Git code repository, MyMigratedApp:
  1. Run the following command to add the newly created Git repository as an origin to the migrated Git repository:
git remote add origin http://Azure DevOps Server2018/Azure DevOps Server/DefaultCollection/PartsUnlimited/_git/MyMigratedApp
  1. Run the following command to push the new Git repository to the remote origin:
git push -u origin –all