![Azure DevOps Server 2019 Cookbook(Second Edition)](https://wfqqreader-1252317822.image.myqcloud.com/cover/627/36698627/b_36698627.jpg)
上QQ阅读APP看书,第一时间看更新
How to do it...
In this section we'll cover the steps for migrating the code from TFVC to git with history:
- 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
- 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
- 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:
![](https://epubservercos.yuewen.com/D90F8A/19470379001491806/epubprivate/OEBPS/Images/b4e15ca9-ada1-40a3-b6b3-538669afc829.png?sign=1738884896-UgymUShylGum2mfCrD85xGQkbm7X76T1-0-b8fee44302f3b5352805194698d059f4)
- 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
- Run the following command to push the new Git repository to the remote origin:
git push -u origin –all