Git 子模块、子存储库还是远程?
我正在使用 GIT 来管理内容管理系统 (CMS) 项目。 CMS可以有多个插件(模块)。
所以基本上,我想要 3 种类型的存储库:
- 核心 CMS 开发(每个新项目都是最后一个稳定和未配置版本的签出)
- 每个模块/插件 1 个存储库。 (每个新项目都会签出他们想要实现的模块的最后一个稳定版本)
- 每个项目 1 个存储库(每个客户端将是一个代表核心 CMS 和模块的个性化的存储库)
对于类型 1 和类型 1 2,我猜这是简单的基本存储库。 但当涉及到客户端项目时,我感到困惑:
- 首先我将克隆 CMS,然后进入 /modules/ 文件夹并再次克隆所有必需的模块?这将在存储库中创建一个存储库!第一个存储库会尝试记录每个模块的 .git/ 文件夹吗?
- 我无法使用子模块,因为每个客户都需要对其模块进行个性化。
- 如果我修改模块的核心组件(不是个性化,只是错误修复),我可以将该单个文件推送到原始模块存储库吗?
- (不是谈论将遍布各处的模块unitTest)
所以问题是: 我应该如何组织存储库/文件/文件夹才能高效?
I'm using GIT to manage a Content Management System (CMS) project. The CMS can have multiple plugin (module).
So basically, I want to have 3 types of repositories:
- The core CMS development ( every new project is a checkout of that last stable & unconfigured version )
- 1 repository per module/plugin. ( 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 )
For the type 1 & 2, I guess it's simple basic repository.
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 ? That will make a repository inside a repository ! Will the first repo will try to log the .git/ folder of each module ?
- 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 )
So the question is:
How should I organize the repository(s) / files / folders in order to be efficient ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您所描述的布局将非常适合 git 子模块。我建议您阅读 文档 并尝试一些教程。您的计划引入的主要区别是每个客户端存储库和客户端插件存储库将有两个遥控器而不是一个。并且,当您想要启动一个新的客户端项目时,您将需要
更好的选择可能是使用相同的存储库并简单地创建一个每个客户的分支机构。我就是这么做的。
The layout you've described will work really well with git submodules. 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
A better option may be to use the same repository and simply make a branch per client. That is how I would do it.
关于上一个答案的简短更新/附加信息:如果您不喜欢 git submodules 方法或认为这太难理解,您可以尝试
git subrepo (子模块的更简单替代方案,位于 Github),
不要忘记检查是否可以使用其他依赖管理器(例如用于 Ruby 的 RubyGems、用于 PHP 的 Composer...)而不是子模块,它会更易于使用和维护。
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 trygit subtrees
(check this article on medium)git subrepo
(easier alternative to submodules, on Github)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.