多个 Git 存储库

发布于 2024-11-27 15:03:50 字数 2385 浏览 1 评论 0原文

我们计划在我们的项目中使用 Git,这是一个在框架上有多个组件的 grails 应用程序。我们计划将框架和每个组件保存在单独的存储库中。因此,根据客户的要求,我们可以混合和匹配组件。组件不能独立运行,它依赖于框架。

以下面的示例为例,其中 A 和 B 是组件,F 是框架,

     F
   /  \
  A    B

因此当我们想要对组件进行一些更改时,我们需要获取组件 A,它应该自动获取 F(框架)。当我们对框架和组件进行更改时,这些更改都应该进入相应的存储库。

我研究了子模块,但 grails 应用程序中遵循的目录结构不适合。应用程序文件如下所示,

Component
    + grails-app
       + conf                 ---> location of configuration artifacts 
           + hibernate        ---> optional hibernate config
           + spring           ---> optional spring config
       + controllers          ---> location of controller artifacts
       + domain               ---> location of domain classes
       + i18n                 ---> location of message bundles for i18n
       + services             ---> location of services
       + taglib               ---> location of tag libraries
       + util                 ---> location of special utility classes 
       + views                ---> location of views
           + layouts          ---> location of layouts

此目录结构后面是所有组件和框架。作为主项目的框架还有一些如下所示的文件,

Framework
    + grails-app
       + conf                 ---> location of configuration artifacts 
           + hibernate        ---> optional hibernate config
           + spring           ---> optional spring config
       + controllers          ---> location of controller artifacts
       + domain               ---> location of domain classes
       + i18n                 ---> location of message bundles for i18n
       + services             ---> location of services
       + taglib               ---> location of tag libraries
       + util                 ---> location of special utility classes 
       + views                ---> location of views
           + layouts          ---> location of layouts
   + lib
   + scripts                  ---> scripts
   + src
       + groovy               ---> optional; location for Groovy source files
                                   (of types other than those in grails-app/*)
       + java                 ---> optional; location for Java source files
   + test                     ---> generated test classes
   + web-app
       + WEB-INF

因此组件文件夹结构和文件被合并在一起以运行应用程序。

请提出这个问题的解决方案。

We plan to use Git for our project which is a grails application have multiple components on the framework. We planned to keep the framework and each and every component in a separate repository. SO that depending upon the customer requirement we can mix and match the components. The components cant not run on its own it depends on the framework.

Take the below example where A and B are the components and F is the Framework,

     F
   /  \
  A    B

So when every we want to do some changes to the component we need to fetch the component A and it should automatically fetch F (Framework). When ever we do the changes to the framework and component both the changes should go the corresponding repository.

I looked into submodules but the directory structure followed in grails application does not suite. The application files are like below,

Component
    + grails-app
       + conf                 ---> location of configuration artifacts 
           + hibernate        ---> optional hibernate config
           + spring           ---> optional spring config
       + controllers          ---> location of controller artifacts
       + domain               ---> location of domain classes
       + i18n                 ---> location of message bundles for i18n
       + services             ---> location of services
       + taglib               ---> location of tag libraries
       + util                 ---> location of special utility classes 
       + views                ---> location of views
           + layouts          ---> location of layouts

This directory structure is followed by all the components and also the framework. The Framework which is the main project has some more file like below,

Framework
    + grails-app
       + conf                 ---> location of configuration artifacts 
           + hibernate        ---> optional hibernate config
           + spring           ---> optional spring config
       + controllers          ---> location of controller artifacts
       + domain               ---> location of domain classes
       + i18n                 ---> location of message bundles for i18n
       + services             ---> location of services
       + taglib               ---> location of tag libraries
       + util                 ---> location of special utility classes 
       + views                ---> location of views
           + layouts          ---> location of layouts
   + lib
   + scripts                  ---> scripts
   + src
       + groovy               ---> optional; location for Groovy source files
                                   (of types other than those in grails-app/*)
       + java                 ---> optional; location for Java source files
   + test                     ---> generated test classes
   + web-app
       + WEB-INF

So the component folder structure and the files are merged together for running the application.

Please propose a solution to this problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

初熏 2024-12-04 15:03:50

查看 git 子模块

Take a look at git submodule.

孤君无依 2024-12-04 15:03:50

这就是 git 子模块 的用途。

This is what git submodules are for.

花心好男孩 2024-12-04 15:03:50

您能做的最好的事情就是使用一个巨大的存储库。这并不漂亮,也绝对不是 git 的标准做法,但确实满足您的要求。

  • 从一个新的存储库开始,例如 ~/main。为此,提交一些基本文件,可能是自述文件,或空的 grails-app 文件夹或类似文件。
  • 创建一个分支,然后将您的框架提交给该分支。您现在有两个分支,以及几乎空的 master 和一个 framework 分支。
  • 为每个组件创建一个新的 master 分支。这些组件的任何开发都需要在这些分支上进行(或者需要对它们的历史进行修改,使其看起来像原来那样)。
  • 每个新项目(~/project1~/project2 等)都将克隆此存储库并使用 master 分支来开发主项目。据推测,前几次提交将是诸如 git merge Framework 和 git merge component-x 之类的命令,以将项目的所有需求获取到 master 中。
  • component-x 的任何改进都需要提交到 component-x 分支。这允许将改进推回主存储库,然后从那里拉到其他项目并合并到它们的 master 分支中。

再说一遍,这主要是黑客行为,如果可能的话,使用子模块会更好。但似乎 grails 并不想很好地处理这个问题。

About the best you can do is use one huge repository. This isn't pretty and definitely isn't standard practice with git, but does satisfy your requirements.

  • Start with a new repository, say ~/main. To this, commit some basic files, perhaps a README, or an empty grails-app folder, or similar.
  • Create a branch, then commit your framework to that. You now have a two branchs, and almost empty master and a framework branch.
  • Create a new branch off master for each component. Any development for these components will need to happen on these branches (or will need to have their history mangled so that it appears like it was).
  • Each new project (~/project1, ~/project2, etc) will clone this repository and use the master branch for development of the main project. Presumably the first few commits will be commands like git merge framework and git merge component-x to get all the requirements for the project into master.
  • Any improvements to component-x will need to be commited to the component-x branch. This allows improvements to be pushed back into the main repository and then pulled from there into other projects and merged into their master branches.

Again, this is mostly hackery, and you would be much, much better using submodules if at all possible. But it seems like grails doesn't really want to play nicely with this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文