简体   繁体   English

Git子模块或子存储库还是远程?

[英]Git submodule or sub-repository or remote?

I'm using GIT to manage a Content Management System (CMS) project. 我正在使用GIT来管理内容管理系统(CMS)项目。 The CMS can have multiple plugin (module). CMS可以有多个插件(模块)。

So basically, I want to have 3 types of repositories: 基本上,我想拥有3种类型的存储库:

  • The core CMS development ( every new project is a checkout of that last stable & unconfigured version ) 核心CMS开发(每个新项目都是最后一个稳定和未配置版本的结帐)
  • 1 repository per module/plugin. 每个模块/插件1个存储库。 ( every new project will checkout the last stable version of the module they want to implement ) (每个新项目都会检查他们想要实现的模块的最后一个稳定版本)
  • 1 repository per project ( each client will be a repository that represent the personalization from the core CMS and the modules ) 每个项目1个存储库(每个客户端将是一个存储库,代表来自核心CMS和模块的个性化)

For the type 1 & 2, I guess it's simple basic repository. 对于类型1和类型2,我猜它是简单的基本存储库。 But when it come to client project, I get confused: 但当涉及到客户项目时,我感到困惑:

  • First I'll clone the CMS, then go in the /modules/ folder and clone again all required modules ? 首先,我将克隆CMS,然后进入/ modules /文件夹并再次克隆所有必需的模块? That will make a repository inside a repository ! 这将在存储库中创建一个存储库! Will the first repo will try to log the .git/ folder of each module ? 第一个repo会尝试记录每个模块的.git /文件夹吗?
  • I can't use submodule as each client needs their modules to be personalized. 我无法使用子模块,因为每个客户端都需要对其模块进行个性化。
  • If I modify a core component of a module ( not a personalization, just a bug fix ), can I push that single file to the original module repository ? 如果我修改模块的核心组件(不是个性化,只是修复错误),我可以将该单个文件推送到原始模块存储库吗?
  • (Not talking of the module unitTest that will be spread all around ) (不是说会传播到周围的模块unitTest)

So the question is: How should I organize the repository(s) / files / folders in order to be efficient ? 所以问题是:我应该如何组织存储库/文件/文件夹以提高效率?

The layout you've described will work really well with git submodules. 你所描述的布局对git子模块非常有效。 I'd gently recommend reading the docs and trying a few tutorials . 我会温和地推荐阅读文档并尝试一些教程 The key difference your plan introduces is that each client repository and client plugin repository will have two remotes instead of one. 您的计划引入的主要区别是每个客户端存储库和客户端插件存储库将具有两个远程控制器而不是一个。 And, when you want to start a new client project you will need to 而且,当您想要启动一个新的客户项目时,您将需要

  1. fork the mainline cms 叉主线cms
  2. fork all of the plugins that will be modified fork所有将被修改的插件
  3. clone the forked cms from (1), update its submodules to point to the new remotes from (2) 从(1)克隆分叉的cms,更新其子模块以指向(2)的新遥控器
  4. initialize/update the submodules 初始化/更新子模块
  5. (optional) add the mainline cms URL as a remote in your client's forked cms (可选)将主线cms URL作为远程添加到客户端的分叉cms中
  6. (optional) add the mainline plugin URLs as remotes in your client's forked plugins (可选)在主客户端的分叉插件中添加主线插件URL作为遥控器

A better option may be to use the same repository and simply make a branch per client. 更好的选择可能是使用相同的存储库,只需为每个客户端创建一个分支。 That is how I would do it. 这就是我要做的。

Short update / additional information about the previous answer: if you don't like git submodules approach or think this is too hard to understand, you can try 关于上一个答案的简短更新/附加信息:如果您不喜欢git submodules方法或认为这太难理解,您可以尝试

Don't forget to check if you can use another depency manager (like RubyGems for Ruby, Composer for PHP...) instead of submodules, it would be easier to use and maintain. 不要忘记检查是否可以使用另一个依赖管理器(如Ruby的RubyGems,PHP的Composer ...)而不是子模块,它将更容易使用和维护。

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

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