简体   繁体   English

从 TFS 迁移后合并 GIT 中的分支

[英]Merge branches in GIT after migration from TFS

We had TFS repository with one branch "Main".我们有一个带有“Main”分支的 TFS 存储库。 Then we branched it to another, "Main-MERGE".然后我们将其分支到另一个“Main-MERGE”。 Both has been long term branches, but in some points we made some merges.两者都是长期分支,但在某些方面我们进行了一些合并。 All works fine.一切正常。

Now we migrated whole repository to GIT using git-tfs.现在我们使用 git-tfs 将整个存储库迁移到 GIT。 All seems to be ok, we are working on both branches in GIT.一切似乎都没问题,我们正在 GIT 的两个分支上工作。

Well, now we decided to merge "Main-MERGE" -> "Main" to have only one "master" branch.好吧,现在我们决定合并“Main-MERGE”->“Main”以只有一个“master”分支。 But it seems to be impossible.但这似乎是不可能的。 Using merge there is no conflict and result is not as expected.使用合并没有冲突,结果不符合预期。 Seems it is more rewrite then merge.似乎更多的是重写然后合并。

Does it mean, that there is no way to merge files as in TFS when branches are migrated to TFS?这是否意味着,当分支迁移到 TFS 时,无法像在 TFS 中那样合并文件? All seems fine in history.历史上的一切似乎都很好。 Migrated commits seems to be connected with parents.迁移的提交似乎与父母有关。 How can I find problem and merge branches?如何找到问题并合并分支?

Update:更新:

You should be able to merge commits which made after migrated normally.您应该能够合并正常迁移后的提交。 It's just like you are working on a new git repo.这就像您正在处理一个新的 git 存储库一样。 For other older commits migrated from TFS, you will be able to see them history info.对于从 TFS 迁移的其他旧提交,您将能够看到它们的历史信息。 But you could not able to merge single commit, they bind together as a new one commit in your Azure DevOps repo.但是您无法合并单个提交,它们作为 Azure DevOps 存储库中的一个新提交绑定在一起。

Op finally get changes back to TFS, then merged and migrated back to GIT. Op 最终将更改返回到 TFS,然后合并并迁移回 GIT。 Took some time, but ok.花了一些时间,但还好。


There are some differences for merge in TFVC and Git: 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 中,合并会影响整个存储库,并且您无法将两组单独的更改视为合并。

When planning your migration you should choose a new branching strategy for Git.在规划迁移时,您应该为 Git 选择一个新的分支策略。

Have no idea why you could not preform merge in Git after your migration.不知道为什么在迁移后无法在 Git 中进行合并。 Suggest you double check your entire process, if there is some missing or wrong.建议您仔细检查整个过程,是否有遗漏或错误。 You could kindly refer this blog with step by step portal: Migrating from TFVC to Git (for large repositories)您可以通过分步门户参考此博客: Migrating from TFVC to Git (for large repositories)

But in your situation, since you are going to combine that two branches and have only one "master" branch in your Git Repo.但是在您的情况下,由于您将合并这两个分支并且在您的 Git 存储库中只有一个“主”分支。

A better way is do the merge before your migration from TFVC to Git.更好的方法是在从 TFVC 迁移到 Git 之前进行合并。 You could have the only "master" branch in TFVC first.您可以首先在 TFVC 中拥有唯一的“主”分支。 After then you could create a branch based on migrated master branch in Git Repo.之后,您可以在 Git Repo 中基于迁移的主分支创建一个分支。

Besides, since through this way only a single branch is migrated.此外,由于通过这种方式只迁移了一个分支。 Migrating only the main branch supports a topic-branch based workflow.仅迁移主分支支持基于主题分支的工作流。 You could also consider to use TFVC Import tool .您也可以考虑使用TFVC 导入工具

More details about migrate from TFVC to Git please kindly take a look at our official tutorial here .有关从 TFVC 迁移到 Git 的更多详细信息,请在此处查看我们的官方教程。

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

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