合并除git子模块或子树合并方法之外的git存储库中子项目中增长的基础项目 [英] Combine a base project that is growing in child projects in git repository except git submodule or subtree merge methods

查看:119
本文介绍了合并除git子模块或子树合并方法之外的git存储库中子项目中增长的基础项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以后会有一些子项目:项目1,项目2等等。另外,还有一个名为的项目:基地项目,是其他项目的基础。 基础项目是一个内容管理系统(CMS)。



所有项目都有自己的git存储库。

项目1,项目2和其他人使用基础项目来开发和发展。

git中有一些类似子模块或子树的方法。但似乎不适合这里。
Base Project不应该克隆到子目录中。它在根目录下。它在项目1或项目2中不断增长......

当我在儿童项目中工作时,必须能够分别推送基础项目更改它是自己的存储库,可以在其他孩子身上获取。



我能做什么? div>

Subtree合并或子模块适用于 基于组件的开发 :两个不同但一致的文件组合在一起。

每个文件集都位于其自己的目录中,因为它们可以分支或独立标记(子模块),或在一起(子树合并,同时保留获取自己的历史的能力)。

两者都需要一个单独的目录。



但是你所描述的内容( Base Project )位于根目录下,增长为项目1 project 2 )是关于 基于系统的方法 :所有组件合并为一个大型组件:一个大集文件,它们将总是一起演化,作为一个单元。

因此,每个项目可以有一个分支: branch1 用于 CMS-projet1 branch2 CMS-project2 等等。但是,如果您需要将 projectx - 特定修改或特定于CMS的修改回复到原始(和单独)回购,然后在专用分支中进行所述特定更改,然后合并这些更改


  • branchp1 会影响 project1

  • branchc1 将会影响 CMS

  • branch1 branchp1 branchc1

$ b $合并的结果b

(对于 branch2 同样的事情)



然后,您可以导出这些更改作为补丁:




  • branchp1 project1 repo

  • from branchc1 to CMS repo



不方便的是Git不记得已经合并回原始回购站的内容,您将在 CMS-projectx 文件集中开发的常见历史记录回原来的 CMS projectx repos。






注意:如果您不想管理2额外的分支,另一个解决方案是:


  • 确保每个提交只包含CMS修改或项目修改

  • 留下一条提交消息,以帮助区分它们( [CMS]我的CMS修改注释... [Project1] my project1修改评论...

  • 使用脚本 git-extract-patches 只能以补丁的形式导出正确的提交。

There are some child projects: "Project 1", "project 2" and so on in the future.

Also, There is a project that named: "Base Project" and it's foundation of other projects. "Base Project" is a content management system (CMS).

All projects have their own git repositories.

"Project 1" , "project 2" and others uses "Base Project" to develop and grow.

There are some methods in git like submodule or subtreemerge. but don't seem to fit here. "Base Project" not should be clone into a sub directory. It's in root directory. It's growing in "project 1" or "project 2"...

When I work in child projects, I have to be able to push "Base Project" changes separately to It's own repository to fetch in other children.

What can I do?

解决方案

Subtree merge or submodules are for a component-based development: two different but coherent set of files combined together.
Each set of files is in its own directory, because they can be branched or labelled independently (submodules), or together (subtree merge, while keeping the ability to get back an history of their own).
Both are requiring a separate directory though.

But what you are describing ("Base Project" is in root directory, growing in "project 1" or "project 2") is about a system-based approach: all components merged into one large component: one large set of file which will always evolve together, as one unit.
So you can have one branch per project: branch1 for CMS-projet1, branch2 for CMS-project2, and so on.

But if you need to report projectx-specific modifications or CMS-specific modifications back to their original (and separate) repos, then make said specific changes in dedicated branches, and then combine those changes:

  • branchp1 would be for changes affecting project1
  • branchc1 would be for changes affecting CMS
  • branch1 would be the result of the merge from branchp1 and branchc1

(same thing for branch2)

You can then export those changes as patches:

  • from branchp1 to project1 repo
  • from branchc1 to CMS repo

The inconvenient is that Git won't remember what has already been merged back to the original repos, but that would allow you to report the common history developed in your CMS-projectx set of files back to your original CMS and projectx repos.


Note: if you don't want to manage 2 extra branches, another solution is to:

  • make sure each commit only include CMS modification OR project modification
  • leave a commit message which helps to distinguish them ("[CMS] my CMS modification comment...", or "[Project1] my project1 modification comment..."
  • use the script git-extract-patches to export as patches only the right commits.

这篇关于合并除git子模块或子树合并方法之外的git存储库中子项目中增长的基础项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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