在我们整个公司,我们是第一个尝试这个的。
\n我们正在尝试将代码从 TFS 获取到 Azure DevOps 中。
\n以下是 TFS 详细信息
\nTFS Server: companyTFS\n\nTFS Project Collection: TechTeam. \n\nTFS Project name: Main.\n\nTFS Branch : Dev\nRun Code Online (Sandbox Code Playgroud)\n现在我正在尝试将代码从 TFS 获取到 Azure DevOps 中。我们可以将代码从 TFS 文件夹复制到 Azure DevOps 文件夹中,但我们不想丢失 TFS 历史记录。
\n如下所述,我安装了Chocolatey 并安装了 gittfs。
\nhttps://blog.rsuter.com/migrate-a-tfs-repository-to-a-vsts-git-repository
\n当我给出以下命令时
\ngit tfs clone http://companyTFS:8080/TechTeam/Main $/Main/Dev/Registration/FeeDetails . \xe2\x80\x93ignore-branches \xe2\x80\x93debug\nRun Code Online (Sandbox Code Playgroud)\n我遇到了异常。
\nTF31002: Unable to connect to this Team Foundation Server: http://companyTFS:8080/TechTeam/Main.\nTeam Foundation Server Url: http://companyTFS:8080/TechTeam/Main.\n\nPossible reasons for failure include:\n- The name, port number, or protocol for the Team Foundation Server is incorrect.\n- The Team Foundation Server is offline.\n- The password has expired or is incorrect.\n\nTechnical information (for administrator):\nThe remote server returned an error: (404) Not Found.\nThe remote server returned an error: (404) Not Found.\nRun Code Online (Sandbox Code Playgroud)\n我也尝试过这个但没有成功。
\nhttps://github.com/microsoft/azure-repos-vscode/issues/320#issuecomment-335573266
\n我想知道我的 TFS 服务器是否可以与外部组件进行握手。
\n如果有人能告诉我我做错了什么,我会很高兴。
\n最后,经过近 4 天的时间,我能够将代码连同历史记录一起从 TFS 移至 Azure DevOps。请参阅下面我所做的所有步骤。
\n安装巧克力:
\n首先我们需要安装 Chocolatey。为了简单起见,我在同一文件夹中创建了以下两个文件。\n文件名:installChocolatey.cmd
\n内容:
\n@echo off\nSET DIR=%~dp0%\n\n%systemroot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "& \'%DIR%install.ps1\' %*"\nSET PATH=%PATH%;%ALLUSERSPROFILE%\\chocolatey\\bin\nRun Code Online (Sandbox Code Playgroud)\n文件名: install.ps1
\n内容:从此处复制粘贴内容https://chocolatey.org/install.ps1
\n在管理模式下打开命令提示符并运行 installChocolatey.cmd 以安装 Chocolatey。
\n在命令提示符下查看choco -v是否安装正确。
安装 git tfs:
\n接下来,我们需要安装git tfs工具,以便在命令提示符中给出以下命令并按照说明进行操作。
\nchoco install gittfs\nRun Code Online (Sandbox Code Playgroud)\n就我而言,它安装到 C:\\Tools\\gittfs。
\n打开环境变量并确保将以下内容(在我的例子中)添加到 PATH 变量中。
\nC:\\工具\\gittfs
\n在命令提示符下输入git tfs -version以查看安装的版本。
\n将代码从 TFS 移至 Azure DevOps:
\nAzure DevOps Project Name: Experiment\nAzure DevOps Repo Name: MyRepo\nAzure DevOps Repo Name: Master and DEV\nRun Code Online (Sandbox Code Playgroud)\n首先,我将此存储库克隆到本地。确保我已将所有远程分支转移到本地分支。
\n在我的本地创建了一个名为 TestBranch 的新分支并将其推送到远程。所以现在 MyRepo 有 3 个分支,TestBranch 是我本地的工作分支。
\n在命令提示符中,我转到映射 Azure DevOps 存储库的文件夹。我给出了以下命令来获取具有历史记录的 TFS 代码。
\ngit tfs clone http://companyTFS:8080/TechTeam $/Main/Dev/Registration/FeeDetails . \xe2\x80\x93debug\nRun Code Online (Sandbox Code Playgroud)\n这将需要一些时间,之后您可以看到 TFS 代码已下载到该文件夹。
\n在同一命令提示符下,
\n给出以下命令以确保您的工作分支是什么
\ngit branch \nRun Code Online (Sandbox Code Playgroud)\n下面的命令将创建一个分支
\ngit checkout -b TempBranch\nRun Code Online (Sandbox Code Playgroud)\n对于以下命令,获取目标 Azure DevOps 存储库的 url。
\n以下命令将把您的远程 Azure DevOps Repo 设置为您想要定位的 Repo
\ngit remote add origin https://xxx@dev.azure.com/xxx/Experiment/_git/MyRepo\nRun Code Online (Sandbox Code Playgroud)\n下面将在 ADO 的目标存储库中创建名为 TempBranch 的新分支。在实验项目和 MyRepo 存储库中
\ngit push --set-upstream origin TempBranch\nRun Code Online (Sandbox Code Playgroud)\n现在,TFS 中的所有代码和历史记录都已进入 Azure DevOps 并进入您的存储库。您可以使用 PULL Request 功能合并到其他分支等。
\n现在假设您希望 Azure DevOps 代码结构有所不同。
\n转到从 TFS 下载代码/历史记录的文件夹,然后创建文件夹结构或更改您想要的方式
\n一一给出以下命令。
\ngit add .\nRun Code Online (Sandbox Code Playgroud)\n要查看所有更改,请输入以下命令
\ngit status\nRun Code Online (Sandbox Code Playgroud)\n在本地提交所有更改
\ngit commit -m "[commit message goes here]"\nRun Code Online (Sandbox Code Playgroud)\n将更改从本地推送到远程的命令\n git push
\n代码将位于实验项目 MyRepo repo TempBranch 分支中
\n| 归档时间: |
|
| 查看次数: |
2408 次 |
| 最近记录: |