简体   繁体   English

适用于不同版本框架的Git工作流程

[英]Git workflow for different versions of a framework

We have the following setup: Three apps which are similar to each other with the common code extracted into a framework. 我们有以下设置:三个相似的应用程序,将公共代码提取到框架中。 Each app is managed in their own git repository and includes the framework as a git submodule. 每个应用程序都在自己的git存储库中进行管理,并将框架作为git子模块包含在内。

The problem is that the apps are now developed in parallel with new features being added to the framework that other apps don't need to support right away. 问题是,现在应用程序与并行开发的新功能被添加到框架中,其他应用程序不需要立即支持。 Currently we have different branches of the framework for all apps. 目前,我们为所有应用程序提供了不同的框架分支。 One app uses the master branch of the framework because most of the time new features were first introduced in this app. 一个应用程序使用框架的主分支,因为大多数时候新功能首次在此应用程序中引入。

Framework branches 框架分支

  • master (used by App A) 主人(由App A使用)
  • appB 程序appB
  • appC APPC

When a new feature is introduced in appB that needed changes in the framework these changes were made to branch appB. 当appB中引入了一个需要在框架中进行更改的新功能时,会对分支appB进行更改。 If these changes were later needed in App A, branch appB was merged into master. 如果以后需要在App A中进行这些更改,则将分支appB合并为master。 This means that all changes in appB had to be merged into master. 这意味着appB中的所有更改都必须合并到master中。

This system worked but had some flaws 这个系统有效,但有一些缺陷

  • merging a feature from one branch to another meant we had to merge all the changes 将一个功能从一个分支合并到另一个分支意味着我们必须合并所有更改
  • easy to loose track what had been merged already or what is going to be merged when merging one branch into another 当将一个分支合并到另一个分支时,容易松散跟踪已经合并的内容或将要合并的内容
  • Marking breaking changes was done using commit messages, which made the last point even more important 使用提交消息标记重大更改,这使得最后一点变得更加重要

We are currently searching for a new workflow. 我们目前正在寻找新的工作流程。 I was think about having the following branches 我考虑过拥有以下分支机构

  • master
  • appA 的appA
  • appB 程序appB
  • appC APPC

So for each app one branch and a master branch that includes all the changes. 因此,对于每个应用程序,一个分支和一个包含所有更改的主分支。 When new features are developed a feature branch should be created and then applied to master as well as to all app branches the feature is needed right away. 在开发新功能时,应创建功能分支,然后将其应用于主分支以及所有应用分支,立即需要该功能。 Other apps can merge the feature branch when they need the feature later on. 其他应用程序可以在以后需要该功能时合并功能分支。

I see the following problems with this 我看到了以下问题

  • How can I merge a feature branch onto multiple branches and only merge the changes that happened in the branch. 如何将功能分支合并到多个分支上,并仅合并分支中发生的更改。 I know of "git rebase onto ..." but I am not quite sure if I can use this command multiple times. 我知道“git rebase into ...”但我不太确定我是否可以多次使用此命令。
  • Should I use git cherry-pick for merging features into multiple branches? 我应该使用git cherry-pick将功能合并到多个分支中吗? I would rather not do this, because I can think that this will be error prone when not selecting all changes that were made in a feature branch 我宁愿不这样做,因为我可以认为当不选择在功能分支中进行的所有更改时,这将容易出错
  • How to keep track of which feature(branch) had been applied to which app. 如何跟踪哪个功能(分支)已应用于哪个应用。 Can I use branch --no-merge or will that only work if the branches have the same ancestor? 我可以使用分支--no-merge,还是仅当分支具有相同的祖先时才能使用?

Is my purposed way the best way to accomplish this or should I rethink my strategy completely? 我的目的是实现这一目标的最佳方式,还是我应该完全重新考虑我的策略?

As explain in " Git & Working on multiple branches ", the two practical solutions when applying commits to multiple branches (which is what you would do with your "feature branches" option) are: 正如“ Git&Working on multiple branches ”中的解释,将提交应用于多个分支时的两个实用解决方案(这是您使用“功能分支”选项所做的)是:

  • merge (which should allow you to keep reusing that feature branch, as it would keep track of what has already been merge to a specific banch): a rebase --interactive might be in order for you to re-order the commits, putting first the ones you want to merge, and then the ones you are nnot ready yet to merge. 合并(这应该允许您继续重用该功能分支,因为它将跟踪已经合并到特定banch的内容): rebase --interactive可能是为了您重新排序提交,首先放置你要合并的那些,然后你尚未准备合并的那些。
  • cherry-picking (and it now supports a range of commits ), but I always have been wary of cherry-picking . 樱桃采摘 (它现在支持一系列的提交 ),但我一直都很喜欢采摘樱桃

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

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