在一个文件夹中使用两个git仓库 [英] Using two git repos in one folder

查看:341
本文介绍了在一个文件夹中使用两个git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是场景:
我目前正在自己​​的框架和客户的网站上工作。这里是结构:

 
..
_application
_framework
_public

我想用_framework / * _public / index.php和github上的结构_application(_controllers _models和_views的空文件夹)进行回购。



我明白,使用git-modules我可以做到这一点,但在查看一些教程后,我仍然不明白这样做的方式。



有人可以向我解释一些吗?非常感谢!

解决方案

在我看来,您可以为每个需要的结构定义一个回购,并将它们结合到一个超级 - 通过子模块完成项目。



请参阅这个问题了解子模块性质的一些细节。



提取:


子模块使您可以拥有 基于组件的方法 开发,其中主要项目仅引用其他组件的特定提交(这里是声明为子模块的其他Git存储库)。

子模块是一个标记(提交)到另一个不受主项目开发周期约束的Git仓库:它(其他Git仓库)可以独立进化。
主项目可以从其他仓库中选择所需的任何提交。



但是,如果您想出于方便考虑修改一个这些子模块直接来自您的主项目,Git允许您这样做,只要您首先将这些子模块修改发布到其原始Git仓库,然后提交您的主项目并参考新版本的子模块。



但主要想法依然存在:引用特定组件:


  • 有自己的生命周期

  • 有自己的一套标签

  • 有自己的开发



您在主项目中提到的特定提交列表定义您的 configuration (这就是配置管理全是ab包括仅仅版本控制系统







所以如果你真的有两种结构可以相互独立演化,子模块是非常合适的。 / p>

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. 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.

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.

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").

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. 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.

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)


So if you really have two structure which can evolve independently one from another, submodules are a good fit.

这篇关于在一个文件夹中使用两个git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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