如何解决Monorepo中的合并冲突? [英] How to resolve merge conflicts in a monorepo?

查看:101
本文介绍了如何解决Monorepo中的合并冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假定以下情况:

  • monorepo在单独的文件夹中包含两个工件,例如前端和后端
  • 前端开发人员无法解决后端代码中的合并冲突
  • 后端开发人员无法解决前端代码中的合并冲突
  • 基于
  • 功能分支的工作流,前端和后端开发人员在相同功能分支上并行工作
  • the monorepo contains two artifacts in separate folders, say frontend and backend
  • frontend developers are not capable of solving merge conflicts in backend code
  • backend developers are not capable of solving merge conflicts in frontend code
  • feature-branch based workflow where frontend and backend developers work in parallel on the same feature branch

当对功能分支的更改(由单独的开发人员创建)在后端和前端代码中发生冲突时,就会出现此问题.单个开发人员(基于上述假设)无法自行进行更新合并.

The problem arises when changes (created by separate developers) on a feature branch conflict in both, backend and frontend code. A single developer (given the mentioned assumptions) is not able to conduct an update-merge on his own.

解决跨越前端后端代码的合并冲突的最佳实践是什么?如果基于垂直功能分支的工作流是根本问题,那么您在坚持前三个假设的情况下如何改进此设置?

What is the best practice to resolve merge conflicts which span frontend and backend code? If the vertical feature-branch based workflow is the underlying problem, how would you improve this setup while sticking with the first three assumptions?

推荐答案

有两种典型的方法可以解决此问题:

There are a couple typical approaches to this problem:

  • 经常合并更改并使用功能标记系统,以便可以将新更改集成而不会生效.这样一来,各个开发人员就可以处理功能的不同方面并逐步进行合并,因此,功能分支仅限于能够单独解决冲突的单个或少数开发人员.
  • 使功能分支作为单个开发人员的功能分支的组合运行,并迫使开发人员各自基于自己的更改,解决冲突,然后将这些单个开发人员分支重新集成到功能分支中.
  • 让各个领域的开发人员结伴在一起,共同解决冲突.

我个人经历了其中的第一和最后一步,我更喜欢前者,但是根据您的工作流程,可能无法实现.例如,如果您有多个开发线(例如,维护和开发分支),则第一个解决方案不能解决您所有的问题,但可以减少它们.

I've personally experienced the first and last of these, and I prefer the former, but depending on your workflow, it may not be possible. For example, if you have multiple lines of development (e.g., a maintenance and a development branch), the first solution won't solve all your problems, but it may reduce them.

通常,您可以设计的工作流程越多,以至于开发人员必须解决的冲突与他们自己正在处理的代码有关,您就越成功.即使同一地区的其他开发人员能够在那里解决冲突,但使用一段代码的开发人员也将能够更快地执行此操作,并且更有可能正确地执行此操作,因为他们目前在使用在那儿工作.

Generally, the more you can design your workflow such that the conflicts a developer has to solve are related to code they themselves are working on, the more successful you'll be. Even if other developers in the same area are capable of resolving conflicts there, the developer working on a piece of code will be able to do it faster and be more likely to do it correctly because they're presently working there.

一种可能的技术方法是使用 git imerge 并隐藏将增量产品作为参考,然后让每个开发人员恢复隐匿状态.尽管可能,但建议不要这样做.这可能很棘手.

A possible technical approach is using git imerge and stashing the incremental products somewhere as a ref, then having each developer resume the stashed state. This is likely to be tricky, though, and while possible, isn't recommended.

这篇关于如何解决Monorepo中的合并冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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