Move code INTO Azure DevOps Repo FROM TFS WITHOUT losing TFS HISTORY

两盒软妹~` 提交于 2020-08-10 22:51:47

问题


In our whole company we are the first one trying this.

We are trying to get the code from TFS into Azure DevOps.

Below is TFS details

TFS Server: companyTFS

TFS Project Collection: TechTeam. 

TFS Project name: Main.

TFS Branch : Dev

Now I am trying to get code from TFS into Azure DevOps. We could have just copied the code from TFS folder into Azure DevOps folder but we do not want to lose the TFS history.

As described in below I installed Chocolatey and also installed gittfs.

https://blog.rsuter.com/migrate-a-tfs-repository-to-a-vsts-git-repository

When I give below command

git tfs clone http://companyTFS:8080/TechTeam/Main $/Main/Dev/Registration/FeeDetails . –ignore-branches –debug

I am getting below exception.

TF31002: Unable to connect to this Team Foundation Server: http://companyTFS:8080/TechTeam/Main.
Team Foundation Server Url: http://companyTFS:8080/TechTeam/Main.

Possible reasons for failure include:
- The name, port number, or protocol for the Team Foundation Server is incorrect.
- The Team Foundation Server is offline.
- The password has expired or is incorrect.

Technical information (for administrator):
The remote server returned an error: (404) Not Found.
The remote server returned an error: (404) Not Found.

I also tried this but did not work.

https://github.com/microsoft/azure-repos-vscode/issues/320#issuecomment-335573266

I am trying to find out whether my TFS server can do handshaking with external components.

I would be glad if someone can tell me what I am doing wrong.


回答1:


At last after spending almost 4 days, I am able to move the code from TFS into Azure DevOps along with history. Please see below all the steps I did.

Install Chocolatey:

First we need to install Chocolatey. To make matters simple I created below two files in same folder. FileName : installChocolatey.cmd

Content:

@echo off
SET DIR=%~dp0%

%systemroot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& '%DIR%install.ps1' %*"
SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

FileName: install.ps1

Content: Copy paste the content from here https://chocolatey.org/install.ps1

Open command prompt in admin mode and ran installChocolatey.cmd to install Chocolatey.

In command prompt give choco -v to see whether it is installed correctly.

Install git tfs:

Next, we need to install git tfs tool in order to do that give below command in command prompt and follow the instructions.

choco install gittfs

In my case it installed to C:\Tools\gittfs.

Open Environment Variables and make sure you add below (in my case )to PATH variable.

C:\Tools\gittfs

In command prompt give git tfs -version to see what version it installed.

Move code from TFS to Azure DevOps:

Azure DevOps Project Name: Experiment
Azure DevOps Repo Name: MyRepo
Azure DevOps Repo Name: Master and DEV

First, I clone this repo to my local. Made sure that I have all remoted branches onto my local.

In my local created a new branch name called TestBranch and pushed it to remote. So now MyRepo has 3 branches and TestBranch is my local working branch.

In command prompt, I went to folder where I mapped Azure DevOps repo. I gave below command to get TFS code with history.

git tfs clone http://companyTFS:8080/TechTeam $/Main/Dev/Registration/FeeDetails . –debug

This will take sometime and after that you can see that TFS code is downloaded to that folder.

In same command prompt,

give below command to make sure what is your working branch

git branch 

Below command will create a branch

git checkout -b TempBranch

For below command get url of your target Azure DevOps repo.

Below command will set your remote Azure DevOps Repo as Repo where you want to target

git remote add origin https://xxx@dev.azure.com/xxx/Experiment/_git/MyRepo

Below will create new branch called TempBranch in your target repo in ADO. Here in Experiment project and MyRepo repo

git push --set-upstream origin TempBranch

Now all your code and history from TFS made its way into Azure DevOps into your Repo. You can use PULL Request feature to merge into other branches and so on.

Now lets say you want your Azure DevOps code structure to be different.

Go to folder where you downloaded code/history from TFS and create folder structure or changes the way you want

Giive below command one by one.

git add .

To see all your changes give below command

git status

To commit all your changes in local

git commit -m "[commit message goes here]"

Command to push the changes from local to remote git push

The code will be in Experiment project MyRepo repo TempBranch branch



来源:https://stackoverflow.com/questions/62764145/move-code-into-azure-devops-repo-from-tfs-without-losing-tfs-history

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!