简体   繁体   English

如何将这个TFVC储存库转换为一个git储存库?

[英]How to convert this TFVC repository to ONE git respository?

Good morning everyone. 大家,早安。

We have a historiclly grown TFVC repository (hosted via TFS Version 15.117.26714.0). 我们有一个历史悠久的TFVC存储库(通过TFS版本15.117.26714.0托管)。 There was never a branch created, everything is just folders. 从来没有创建过分支,所有的都只是文件夹。 The current structure is something like: 当前的结构类似于:

/project/trunk/application1
/project/trunk/application2
/project/branches/release1/application1
/project/branches/release1/application2
/project/branches/release2/application1
/project/branches/release2/application2

Where every release has multiple bugfix-commits, because we have to maintain older releases for our customers. 每个版本都有多个bugfix-commit,因为我们必须为客户维护较旧的版本。 The first commit is from 2011 and we are going strongly to the 100.000st changeset. 第一次提交是从2011年开始,我们将大力推进第100.000个变更集。 Currently we just make commits where ever we like, but since the team has grown, the growing pains also havent gotten any better. 目前,我们只是在自己喜欢的地方做出承诺,但是由于团队的成长,成长的痛苦也没有得到改善。

This setup is used in multiple projects. 此设置用于多个项目。

We would now like to move to a more modern approach of making commits, like feature branches, pull request and easy to do code reviews. 现在,我们想转向一种更现代的提交方法,例如功能分支,提取请求和易于执行的代码审查。 Especially the code reviews are currently a huge pain, because we have to cross-check every changeset of relevance. 尤其是代码审查目前非常痛苦,因为我们必须交叉检查每个相关的变更集。

Sadly we discovered that TFVC is unable to do Pull-Request, so we would like to move to git, but we want to keep our commit history. 遗憾的是,我们发现TFVC无法执行Pull-Request,因此我们想转到git,但是我们希望保留提交历史记录。

For conversioning our TFVC repository to git, we found the tool git-tfs, with which we were able to convert each folder into a single git repository by converting the folders trunk, release 1 and release 2 (from the sketch above) into branches and executing the command: 为了将TFVC存储库转换为git,我们找到了工具git-tfs,使用该工具,我们可以通过将文件夹主干,发行版1和发行版2(根据上面的草图)转换为分支和将每个文件夹转换为单个git存储库。执行命令:

"C:\Program Files\git-tfs\git-tfs.exe" clone https://dev.azure.com/userName1234/ "{branchName}" . --branches=auto

By adding the other repositories as remote, one can see the branches nicely next to each other. 通过将其他存储库添加为远程存储库,可以很好地看到分支。

But this results in A LOT of repositories. 但这会导致很多存储库。 In our case it would end up to be 46 (!) repositories for our biggest project. 对于我们来说,最大的项目将是46(!)个存储库。 This wouldn't be very nice, to say the least. 至少可以这样说,这不是很好。 Also this would mean, that depending on which version we have to create a bugfix for, we have to either change to another repository or search for the release branch from the master branch, which would mean two workflows for something that should be only one. 这也意味着,根据我们必须为其创建错误修复程序的版本,我们必须更改为另一个存储库,或者从master分支中搜索release分支,这意味着两个工作流仅应是一个。

Is there a way to convert all those repositories into one repository, where the trunk is the master branch and the releases are branches of that master branch? 有没有一种方法可以将所有这些存储库转换为一个存储库,其中主干是主分支,而发行版是该主分支的分支? At least from a human perspective, they are nicely distinguishable, as shown in this screenshot of a test-setup of our situation: 至少从人类的角度来看,它们是可以很好区分的,如下面这种情况的测试设置的屏幕截图所示:

测试设置的屏幕截图,表示当前的问题

The Git-TFS tool is a two-way bridge between Team Foundation Version Control and Git, and can be used to perform a migration. Git-TFS工具是Team Foundation版本控制和Git之间的双向桥梁,可用于执行迁移。 Git-TFS is appropriate if you want to attempt a migration with full history, more than the 180 days that the Import tool supports, or if you want to attempt a migration that includes multiple branches and merge relationships. 如果您想尝试具有完整历史记录,超过导入工具支持的180天的迁移,或者想要尝试包含多个分支和合并关系的迁移,则Git-TFS是合适的。

However as you mentioned, there are all folders not any branch in TFVC workspace. 但是,正如您提到的,TFVC工作空间中没有文件夹,而没有任何分支。 You should select a branching strategy for them first. 您应该首先为它们选择分支策略。 And later convert them to Git branch. 然后将它们转换为Git分支。

Before you attempt a migration with Git-TFS, since TFVC is a centralized version control system,Git stores information about file history and branches in a way that is fundamentally different from a centralized version control system. 在尝试使用Git-TFS进行迁移之前,由于TFVC是集中式版本控制系统,因此Git以与集中式版本控制系统根本不同的方式存储有关文件历史记录和分支的信息。

  • Git stores history as a snapshot of the repository in time, while TFVC records the discrete operations that occurred on a file. Git及时将历史记录存储为存储库的快照,而TFVC记录文件中发生的离散操作。 Change 更改
    types in TFVC like rename, undelete and rollback cannot be expressed 无法表示TFVC中的类型,例如重命名,取消删除和回滚
    in Git; 在Git中; instead of seeing that file A was renamed to file B, you may 而不是看到文件A被重命名为文件B,您可能
    only see that file A was deleted and file B was added in the same 只看到文件A被删除,文件B被添加到同一文件中
    commit. 承诺。
  • Git does not have a direct analog of a TFVC label: labels can contain any number of files at any specific version and can reflect files at different versions. Git没有TFVC标签的直接类似物:标签可以包含任何特定版本的任何数量的文件,并且可以反映不同版本的文件。 Although conceptually similar, Git tags point to a snapshot of the whole repository at a point in time. 尽管从概念上讲,Git标签在某个时间点指向整个存储库的快照。 If you rely on TFVC labels to know what was delivered, Git tags may not be provide this information. 如果您依靠TFVC标签来了解交付了什么,则可能不会提供Git标签。
  • Merges in TFVC occur at the file level, not at the entire repository. TFVC中的合并发生在文件级别,而不是整个存储库。 You can merge only a subset of changed files from one branch to another, then merge the remaining changed files in a subsequent changeset. 您只能将更改文件的一个子集从一个分支合并到另一个分支,然后将剩余的更改文件合并到后续的更改集中。 In Git, a merge affects the entire repository, and you cannot see both sets of individual changes as a merge. 在Git中,合并会影响整个存储库,您无法将两组单独的更改都视为合并。

Source Link 源链接

Because of these differences, we generally advise users to do a tip migration and keep their TFVC repository online but read-only to view history. 由于存在这些差异, 我们通常建议用户进行提示迁移,并使其TFVC存储库保持联机状态,但只读以查看历史记录。

This is the approach that Microsoft took when it migrated Windows and other products from centralized version control to Git. 这是Microsoft将Windows和其他产品从集中版本控制迁移到Git时采用的方法。

For tip migration, kindly refer the official TFVC import tool (single branch based). 对于技巧迁移,请参考官方的TFVC导入工具 (基于单个分支)。

For using git-tfs, you could follow Daniel Mann's suggestion establish a branch hierarchy for your folders in TFVC so that git-tfs can treat them as Git branches. 对于使用git-tfs,您可以按照Daniel Mann的建议在TFVC中为文件夹建立分支层次结构,以便git-tfs可以将它们视为Git分支。 A command for your reference git tfs xxx branch -init --all 供您参考的命令git tfs xxx branch -init --all

As for how to establish branch for folders, you could take a look at our official tutorial convert a Folder to a Branch . 至于如何为文件夹建立分支,您可以看一下我们的官方教程《 将文件夹转换为分支》

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

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