使用从中提交提交的Git子模块时有什么选项? [英] What are the options when working with Git submodules from which commits are made?

查看:124
本文介绍了使用从中提交提交的Git子模块时有什么选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在工作中,我们正在研究十几个Java OSGi包,每个包都有自己的git存储库。从长远来看,所有捆绑包都是相互独立的,这证明了各个存储库的正确性 - 尽管现在我们仍然经常同时修改其中的几个。



当我们制作一个产品发行版(包含所有包)时,每个包中都会创建一个新的分支,这有点痛苦。因此,我们考虑使用git-submodule来缓解痛苦(类似于 git submodule foreach< cmd> )。



因此,我们所需的设置将是一个主项目 Product ,以及每个包的子模块:

  Project / 
BundleA /
BundleB /
BundleC /

现在,我花了几个小时阅读我所能找到的关于子模块的所有内容,并且我明白如果我修改 BundleA 中的所有内容,我必须在 BundleA 中提交,然后推送,然后在 Project 中提交子模块更改,然后再次推送。



这听起来不像git-submodule是如何设计用于首位的。这是否违背了最佳实践?或者它听起来像是一种情况下的替代方案会被优先考虑?




  • 裸机git子模块用法

  • 使用现有的git wrapper:


  • 编写我自己的简单bash脚本来批处理OSGi包

  • ul>

    欢迎任何其他建议。

    解决方案

    您不需要保留跟踪子项目在超级项目中的作用(紧密绑定),那么我建议你远离git-submodules。



    gitslave(http://gitslave.sf .net)本质上是一个很大的foreach,每个子项目在超级项目中都有一个配置文件,列出了子项目。有许多花里胡哨的东西使它更方便,但如果你的目标是在超级项目(可选)和所有子项目上运行相同的命令,gitslave就像你要找的那样方便。



    例如,在gitslave中创建一个新的分支是:

    gits checkout -b newbr



    然后,您的超级项目和所有子项目都将创建新分支并进行更改。一般来说,如果你想对超级项目的所有成员运行一个gits命令,只需将git命令改为gits即可。


    At work, we're working on a dozen Java OSGi bundles, each of which has its own git repository. All bundles will be, in the long run, pretty independent from each other, which justifies the individual repositories — although right now we're still often modifying several of them at the same time.

    When we make a product release (which consists of all bundles), a new branch is created in each bundle, which is a bit of a pain. We were thus thinking about using git-submodule to ease the pain (something like git submodule foreach <cmd>).

    So, our desired setup would be a master project Product, and submodules for each bundle:

    Project/
      BundleA/
      BundleB/
      BundleC/
    

    Now, I've spent several hours reading all I could find about submodules, and I understood that if I modify things in BundleA, I have to commit in BundleA, push, then commit the submodule change in Project and push again.

    This clearly sounds like it was not how git-submodule was designed to be used in the first place. Is it against best practices to use it like this? Or does it sound like a case where an alternative would be preferred?

    • bare-bones git-submodule usage
    • using an existing "git wrapper":
    • write my own simple bash scripts to batch process the OSGi bundles

    Any other suggestion welcome.

    解决方案

    It you do not need to keep track of what the subproject is doing in the superproject (tight binding) then I recommend you stay far away from git-submodules.

    gitslave (http://gitslave.sf.net) is essentially a large foreach around each of the subprojects with a config file in the superproject listing the subprojects. There are lots of bells and whistles which make it more convenient, but if your goal is to run the same command on the superproject (optional) and all of the subprojects, gitslave is about as convenient as you are going to find.

    So for example, to create a new branch in gitslave is:

    gits checkout -b newbr

    Then your superproject and all of the subprojects will create the new branch and change to it. In general, if you want to run a gits command on all members of the superproject, just change the "git" command to "gits".

    这篇关于使用从中提交提交的Git子模块时有什么选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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