如何使用子模块和n层git存储库策略 [英] How to work with submodules and n-tiers git repository strategies

查看:99
本文介绍了如何使用子模块和n层git存储库策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在迁移到git。我们有大量的模块组成我们的产品,其中一些是产品之间共享的。该产品由仅包含子模块的瘦超级存储库(ssh://server/product.git)表示:

  [submodulemodule1] 
path = module1 $ b $ url = ssh://server/product/module1.git
[submodulemodule2]
path = module2
url = ssh://server/product/module2.git
...

我可以克隆超级存储库并使用子模块并提交它们,然后将子模块提交到超级存储库。



问题出现在我想介绍另一层时。有两个基本的场景(这可以结合起来做出更复杂的设置,但任何东西都应该是这些场景的组合):


  1. 作为开发人员,我克隆了一个中央存储库并开展工作。然后,我想在将我的更改合并到中央存储库之前将我的代码提交给持续集成服务器。我让CI服务器克隆我的回购。这不起作用,CI服务器将克隆我的超级repo,然后它将从中央资源库位置克隆子模块(因为这就是它在.gitmodules中所说的内容)。


  2. 作为一个团队,我们希望拥有一个集成存储库,在我们之前,在sprint结束之前,我们将我们的代码合并到中央存储库。出于同样的原因,这失败了。

我试着指定子模块的相对URL,但这也不起作用,因为当我们克隆第二层到第三层相对URL相对于第二层存储库位置解析,但第二层子模块位置在第二层超级存储库内。



我可以兼得吗? Git子模块和n层存储库结构?解决方案

如果我正确理解你,你希望在其他的git子模块中子模块,并且能够检出顶层存储库,并正确检出嵌套子模块的所有层?我从来没有做过这件事,但你可能会发现子模块内部的Git子模块(嵌套子模块) 好读。


We are migrating to git. We have a large number of modules that make up our products, some of them are shared between products. The product is represented by a "thin" super repository (ssh://server/product.git) that only contains submodules:

[submodule "module1"]
path=module1
url=ssh://server/product/module1.git
[submodule "module2"]
path=module2
url=ssh://server/product/module2.git
...

I can clone the super repository and work with the submodules and commit them, and then commit the submodules to the super repository.

The problem comes when I want to introduce another tier. There are two basic scenarios (this can combine to make more complex setups, but anything should be a combination of these):

  1. As a developer, I clone a central repository and work. Then I want to submit my code to our continuous integration server before merging my changes to the central repository. I let the CI server clone my repo. This doesn't work, the CI server will clone my super repo and then it will clone the submodules from the central repository location (since that is what it says in .gitmodules).

  2. As a team we want to have an integration repository that we work towards before we, at the end of a sprint, merge our code to the central repository. This fails, for the same reason.

I tried specifying relative URLs for the submodules, but this doesn't work, either, since when we clone the second tier into the third tier the relative URLs resolve relative to the second tier repository location, but the second tier submodule locations are inside the second tier super repository.

Can I have it both? Git submodules and n-tier repository structure?

解决方案

If I understand you correctly, you're wanting to have git submodules within other submodules, and be able to check out the top level repository and have all the n layers of nested submodules be checked out correctly?

I've never done this myself, but you might find Git submodule inside of a submodule (nested submodules) a good read.

这篇关于如何使用子模块和n层git存储库策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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