简体   繁体   English

仅将部分TFS存储库迁移到Azure DevOps上的Git

[英]Migrate only part of TFS repository to Git on Azure DevOps

I am new to a company and my boss wants me to set up a proper Git repository to replace the existing TFVC repo. 我是公司的新手,我的老板要我设置一个合适的Git存储库来替换现有的TFVC存储库。 My company has dozens of .NET solutions for various separate products all in a single repo all in separate folders. 我的公司在单个仓库中为各种单独的产品提供了数十种.NET解决方案,所有这些都在单独的文件夹中。 These solutions are in child folders to the overarching folder which houses the entire repo (with 3 branches labeled dev, main, and master). 这些解决方案位于包含整个仓库的整个文件夹的子文件夹中(有3个分支标记为dev,main和master)。

I have two questions: 我有两个问题:

1) How do I get only one of these solutions into a single Git repository to move into our new Azure DevOps branch? 1)如何只将其中一个解决方案放入一个Git存储库,以便迁移到我们的新Azure DevOps分支? Which tools should I use in this case? 在这种情况下我应该使用哪些工具? Azure DevOps itself or combination of git-tf or git tfs command line? Azure DevOps本身还是git-tf或git tfs命令行的组合? Ok that was 3 questions in one. 好的,这是一个3个问题。

2) TFS has three branches: dev, main, and master (which are parents of the solution folders). 2)TFS有三个分支:dev,main和master(它们是解决方案文件夹的父级)。 How do I get just one of these branches to be brought over into Git (ie. I just want Master brought over)? 我如何让这些分支中的一个被带入Git(即我只是想让Master带过来)? Must I include all branches? 我必须包括所有分支吗?

So 2 groups of questions, but are actually 5 loaded questions. 所以有2组问题,但实际上是5个问题。 I apologize, but this is a tricky situation. 我道歉,但这是一个棘手的情况。 Thank you in advance. 先感谢您。

I write this with an assumption about your strategy: 我写这个是关于你的策略的假设:

The answers below have a flavor that comes from assuming you want to propagate the repo-per-sln methodology. 下面的答案有一种味道,假设您想要传播repo-per-sln方法。 "Is it better for us to get everything into one git repo fast and separate later, or move to git piece by piece?" “对于我们来说,将所有内容快速地放入一个git仓库并在以后分开,或者逐个移动到git是否更好?” Is a real question to ask. 这是一个真正的问题。 I have only been part of 1 migration that did the whole hog, and the coordination effort was significant, because ppl went home on Friday using TFVC but came in on Monday using Git. 我只是参与了整个生猪的一次迁移的一部分,协调努力很重要,因为周五使用TFVC回家了,但周一使用Git进入。

I bring this up because you mention that your boss 我提起这件事是因为你提到了你的老板

wants [you] to set up a proper Git repository to replace the existing TFVC repo 希望[你]建立一个合适的Git存储库来替换现有的TFVC存储库

The use of "a proper Git repo" (singular) may change the way you need to thing about things, particularly on the AzDO CI/CD front. 使用“合适的Git repo”(单数)可能会改变您对事物的需求方式,特别是在AzDO CI / CD前端。

On to (my version of) the answers: 转到(我的版本)答案:

How do I get only one of these solutions into a single Git repository 我如何只将其中一个解决方案放入一个Git存储库中

If the solutions are truly separate, and you don't have dependencies on other solutions, then create a directory with the name you like for your repo and give it the good ol' copy-paste treatment. 如果解决方案是真正独立的,并且您没有其他解决方案的依赖关系,那么创建一个目录,其中包含您喜欢的repo名称,并为其提供良好的复制 - 粘贴处理。 Then you can init a git repo there (don't forget to include a good .gitignore file for VS projects) and commit the initial changes. 然后你可以在那里初始化一个git repo(不要忘记为VS项目包含一个好的.gitignore文件)并提交初始更改。 Then you can setup the AzDO project repo as the remote to push to. 然后,您可以将AzDO项目仓库设置为要推送到的远程。

If you're new to Git, you may want to init the repo on AzDO and clone locally rather than manually setting up AzDO as a remote for a repo you created locally. 如果你是Git的新手,你可能想要在AzDO上初始化repo并在本地克隆,而不是手动将AzDO设置为你在本地创建的repo的远程。 Then you can still use the hammer (read: copy/paste) to get your TFVC code into your new git repo. 然后你仍然可以使用锤子(阅读:复制/粘贴)将你的TFVC代码放入你的新git仓库。

If the solutions are inter-dependent with project and assembly references, you'll need to really think about strategy here. 如果解决方案与项目和程序集引用相互依赖,那么您需要在此处真正考虑策略。 In my latest migration, we have opted to use NuGet packages to deliver components that are shared across multiple services or products. 在我最近的迁移中,我们选择使用NuGet包来提供跨多个服务或产品共享的组件。 In cases like this, you'll probably want to start with the shared code. 在这种情况下,您可能希望从共享代码开始。 Getting that stuff in its own place, and implementing a strategy for delivery is a good place to start and will give you a real idea of what the migration is going to take. 将这些东西放在自己的位置,并实施交付策略是一个很好的起点,可以让您真正了解迁移将采取的措施。

Which tools should I use in this case? 在这种情况下我应该使用哪些工具?

I tend to use Git Bash for most things like this, but "to each his own". 对于像这样的大多数事情,我倾向于使用Git Bash,但是“对每个人来说都是如此”。 As @DanielMann mentioned, your tool will be defined by what you really need history-wise. 正如@DanielMann所提到的,您的工具将根据您真正需要的历史来定义。 I have sided with his opinion in all of my migrations so far. 到目前为止,我在所有的迁移中都支持他的观点。 "Let the past be the past." “让过去成为过去。” This latest migration has also opted to abandon the on-prem Team City build configurations in favor of a pure AzDO implementation for SC >> CI >> CD. 最新的迁移也选择放弃了本地Team City构建配置,转而使用SC >> CI >> CD的纯AzDO实现。

2) TFS has three branches: dev, main, and master (which are parents of the solution folders). 2)TFS有三个分支:dev,main和master(它们是解决方案文件夹的父级)。 How do I get just one of these branches to be brought over into Git (ie. I just want Master brought over)? 我如何让这些分支中的一个被带入Git(即我只是想让Master带过来)? Must I include all branches? 我必须包括所有分支吗?

I'm going to reverse the order of these 2 questions: 我要颠倒这两个问题的顺序:

Must I include all branches? 我必须包括所有分支吗?

No. TFVC tracks files, so each branch has its own piece of the file system. TFVC跟踪文件,因此每个分支都有自己的文件系统。

2) TFS has three branches: dev, main, and master (which are parents of the solution folders). 2)TFS有三个分支:dev,main和master(它们是解决方案文件夹的父级)。 How do I get just one of these branches to be brought over into Git (ie. I just want Master brought over)? 我如何让这些分支中的一个被带入Git(即我只是想让Master带过来)?

Again, use the hammer. 再次,使用锤子。 You should create a new area of your local file system to represent the repo(s). 您应该创建本地文件系统的新区域来表示存储库。 For example: my repo container is c:/src/ then I have the directories representing each individual repo c:src/r1/ c:src/r2/ ect. 例如:我的repo容器是c:/src/然后我有代表每个repo c:src/r1/的目录c:src/r1/ c:src/r2/ ect。 (note: my names are way better than what's in the example). (注意:我的名字比示例中的更好)。 Once you have this, get latest from the desired TFVC branch and hammer away. 一旦你有了这个,从所需的TFVC分支获取最新信息并锤掉。

Possible headache 可能头痛

Make sure you can get other developers to stop making changes to the code you're migrating. 确保您可以让其他开发人员停止对您要迁移的代码进行更改。 If you're setting up an AzDO CI/CD pipeline too, you may end up making changes to the projects to get that working. 如果您也正在设置AzDO CI / CD管道,您可能最终会对项目进行更改以使其正常工作。 If devs are still changing the source you're working on, you will want to echo your changes in TFVC for them to write on top of, else you'll be in merge hell when you try to hammer the new changes back into git. 如果开发人员仍然在改变您正在处理的源代码,那么您将希望在TFVC中回显您的更改,以便他们在上面编写,否则当您尝试将新更改重新添加到git中时,您将处于合并状态。

The point 2) make it easier to migrate. 第2点)使迁移更容易。

So it should be done without too much problem, with a command similar to : 所以它应该没有太多问题,使用类似于的命令:

git tfs clone https://tfs.codeplex.com:443/tfs/Collection $/project/trunk --branches=none

See https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/migrate_tfs_to_git.md#fetch-all-the-history-for-just-the-main-branch-ignoring-all-the-other-branches 请参阅https://github.com/git-tfs/git-tfs/blob/master/doc/usecases/migrate_tfs_to_git.md#fetch-all-the-history-for-just-the-main-branch-ignoring-all -the-其他分支

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM