将代码从TFS移到Azure DevOps存储库中,而不会丢失TFS历史记录 [英] Move code INTO Azure DevOps Repo FROM TFS WITHOUT losing TFS HISTORY

查看:181
本文介绍了将代码从TFS移到Azure DevOps存储库中,而不会丢失TFS历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们整个公司中,我们是第一个尝试这样做的人.

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

我们正在尝试将代码从TFS导入Azure DevOps .

下面是TFS详细信息

TFS Server: companyTFS

TFS Project Collection: TechTeam. 

TFS Project name: Main.

TFS Branch : Dev

现在,我正在尝试将代码从TFS导入Azure DevOps. 我们可以将代码从TFS文件夹复制到Azure DevOps文件夹中,但我们不想丢失TFS历史记录.

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.

如下所述,我安装了巧克力,还安装了gittfs .

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

当我给出以下命令时

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

我正处于例外之下.

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

我正在尝试确定我的TFS服务器是否可以与外部组件进行握手.

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.

推荐答案

最后花了近4天的时间,我才能将代码连同历史记录从TFS移到Azure DevOps中.请在下面查看我执行的所有步骤.

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.

安装Chocolatey:

首先,我们需要安装Chocolatey.为简单起见,我在同一文件夹中的两个文件下面创建了文件. 文件名:installChocolatey.cmd

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

内容:

@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

文件名:install.ps1

内容:从此处复制粘贴内容 https://chocolatey.org/install.ps1

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

在管理员模式下打开命令提示符,然后运行installChocolatey.cmd以安装Chocolatey.

在命令提示符下,输入choco -v以查看其是否正确安装.

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

安装git tfs:

接下来,我们需要安装 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

就我而言,它已安装到C:\ Tools \ gittfs.

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

打开环境变量,并确保您在下面(以我为例)添加到PATH变量.

C:\ Tools \ gittfs

在命令提示符下,提供 git tfs -version 以查看其安装的版本.

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

将代码从TFS移至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.

在我的本地环境中创建了一个名为TestBranch的新分支名称,并将其推送到远程.因此,现在MyRepo有3个分支,而TestBranch是我的本地工作分支.

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.

在命令提示符下,我转到了映射Azure DevOps存储库的文件夹.我给了以下命令以获取带有历史记录的TFS代码.

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

这将需要一些时间,之后您将看到TFS代码已下载到该文件夹​​.

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

在同一命令提示符下,

提供以下命令以确保您的工作分支是

give below command to make sure what is your working branch

git branch 

下面的命令将创建一个分支

Below command will create a branch

git checkout -b TempBranch

对于以下命令,获取目标Azure DevOps存储库的URL.

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

以下命令会将您的远程Azure DevOps存储库设置为您要定位的存储库

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

下面将在ADO的目标存储库中创建一个名为TempBranch的新分支.在实验项目和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

现在,来自TFS的所有代码和历史记录都已进入Azure DevOps并进入了Repo.您可以使用PULL Request功能合并到其他分支,依此类推.

现在可以说您希望您的Azure DevOps代码结构有所不同.

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

转到从TFS下载代码/历史记录的文件夹,然后创建文件夹结构或更改所需的方式

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

下面一个命令给与我.

git add .

要查看所有更改,请在下面提供命令

To see all your changes give below command

git status

要在本地提交所有更改

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

命令将更改从本地推送到远程 git push

Command to push the changes from local to remote git push

代码将在实验"项目MyRepo repo TempBranch分支中

这篇关于将代码从TFS移到Azure DevOps存储库中,而不会丢失TFS历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆