简体   繁体   English

在一个文件夹中使用两个git repos

[英]Using two git repos in one folder

Here's the scene: I'm currently working on my own framework and on a client's website. 现在是这样的场景:我正在开发自己的框架和客户的网站。 Here is the structure: 这是结构:

.
..
_application
_framework
_public

I'd like to have a repo with _framework/* _public/index.php and the structure _application (empty folders for _controllers _models and _views) on github. 我想在github上使用_framework / * _public / index.php和_controllers _models和_views的结构_application(空文件夹)进行回购。 Also I'd like to have a repo containing ALL of this locally. 另外,我想在当地有一个包含所有这些的回购。

I understood that with git-modules I could do this, but after looking up some tutorials I still don't understand the way of doing this. 我理解使用git-modules我可以做到这一点,但在查找了一些教程后,我仍然不明白这样做的方法。

Could someone explain it a bit more to me? 有人可以向我解释一下吗? Thanks a lot! 非常感谢!

It seems to me that you could define one repo per structure you want, and combine them in a super-project through submodules . 在我看来,你可以为你想要的每个结构定义一个repo,并通过子模块将它们组合在一个超级项目中。

See this question for some details on the nature of submodules. 有关子模块性质的一些详细信息,请参阅此问题

Extract: 提取:

A submodule enables you to have a component-based approach development, where the main project only refers to specific commits of other components (here "other Git repositories declared as sub-modules"). 子模块使您可以进行基于组件的方法开发,其中主项目仅引用其他组件的特定提交(此处“声明为子模块的其他Git存储库”)。

A submodule is a marker (commit) to another Git repository which is not bound by the main project development cycle: it (the "other" Git repo) can evolves independently. 子模块是另一个Git存储库的标记(提交),它不受主项目开发周期的约束:它(“其他”Git存储库)可以独立发展。 It is up to the main project to pick from that other repo whatever commit it needs. 主要项目取决于其他任何需要提交的回购。

However, should you want to, out of convenience, modify one of those submodules directly from your main project, Git allows you to do that, provided you first publish those submodule modifications to its original Git repo, and then commit your main project referring to a new version of said submodule. 但是,为了方便起见,您希望直接从主项目中修改其中一个子模块,Git允许您这样做,前提是您首先将这些子模块修改发布到其原始Git仓库,然后提交您的主项目参考所述子模块的新版本。

But the main idea remains: referencing specific components which: 但主要的想法仍然是:引用以下特定组件:

  • have their own lifecycle 有自己的生命周期
  • have their own set of tags 有自己的标签集
  • have their own development 有自己的发展

The list of specific commits you are referring to in your main project defines your configuration (this is what Configuration Management is all about, including mere Version Control System ) 您在主项目中引用的特定提交列表定义了您的配置 (这就是Configuration Management的全部内容,包括纯粹的版本控制系统


So if you really have two structure which can evolve independently one from another, submodules are a good fit. 因此,如果你真的有两个可以独立进化的结构,子模块是一个很好的选择。

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

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