多个 Git 存储库
我们计划在我们的项目中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 git 子模块。
Take a look at git submodule.
这就是 git 子模块 的用途。
This is what git submodules are for.
您能做的最好的事情就是使用一个巨大的存储库。这并不漂亮,也绝对不是
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.~/main
. To this, commit some basic files, perhaps a README, or an empty grails-app folder, or similar.master
and aframework
branch.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).~/project1
,~/project2
, etc) will clone this repository and use themaster
branch for development of the main project. Presumably the first few commits will be commands likegit merge framework
andgit merge component-x
to get all the requirements for the project intomaster
.component-x
will need to be commited to thecomponent-x
branch. This allows improvements to be pushed back into the main repository and then pulled from there into other projects and merged into theirmaster
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.