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

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

问题描述

场景如下:我目前正在开发我自己的框架和客户的网站.这是结构:

<预><代码>..._应用_框架_上市

我想在 github 上有一个带有 _framework/* _public/index.php 和结构 _application(_controllers _models 和 _views 的空文件夹)的仓库.此外,我想在本地拥有一个包含所有这些内容的存储库.

我知道使用 git-modules 我可以做到这一点,但是在查阅了一些教程之后我仍然不明白这样做的方式.

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

解决方案

在我看来,你可以为每个你想要的结构定义一个 repo,并通过子模块将它们组合在一个超级项目中.

有关子模块性质的一些详细信息,请参阅这个问题.

提取:

<块引用>

子模块使您能够采用基于组件的方法 开发,其中主项目仅指其他组件的特定提交(此处为声明为子模块的其他 Git 存储库").

子模块是另一个 Git 存储库的标记(提交),它不受主项目开发周期的约束:它(另一个"Git 存储库)可以独立发展.由主项目从其他存储库中选择它需要的任何提交.

但是,为了方便起见,如果您想直接从主项目中修改这些子模块之一,Git 允许您这样做,前提是您首先将这些子模块修改发布到其原始 Git 存储库,然后提交您的主项目项目指的是所述子模块的新版本.

但主要思想仍然是:引用特定组件:

  • 有自己的生命周期
  • 有自己的标签集
  • 有自己的发展

您在主项目中所指的特定提交列表定义了您的配置(这就是配置管理的全部内容,仅包括版本控制系统)

<小时>

因此,如果您确实有两种可以相互独立演化的结构,则子模块非常适合.

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 repos的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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