尝试找出在 git 中使用子模块的正确方法
我正在尝试在 git 中正确设置子模块,并且我想确保我正确使用它。
我有一个名为 MyProject
的主存储库。我有一个辅助存储库,其中包含所有代码生成的数据访问,称为 Data
。我想将 Data
设置为 MyProject
的子模块。
数据
很少发生变化,除非有架构更改或小错误修复。
假设我要向 MyProject
添加一些新功能,这需要更改架构。通常,我会创建一个名为 NewFeature
的 MyProject
分支,并在那里签入我的所有更改,直到它准备好与 master 合并。我还想为 Data
创建一个分支,以便任何架构更改都与 Master
保持独立,直到我的更改准备好合并为止。
正确的工作流程是什么,或者是否有一个?
谢谢!
I'm trying to get a submodule setup properly in git and I want to make sure I use it right.
I have main repository called MyProject
. I have a secondary repository that contains all of our code generated data access called Data
. I want to setup Data
as a submodule of MyProject
.
Data
rarely changes unless there is a schema change, or a small little bug fix.
Let's say I'm adding some new functionality to MyProject
which requires a schema change. Typically I would create a branch of MyProject
called NewFeature
and check in all my changes there until it's ready to be merged with master. I also want to create a branch for Data
so that any schema changes stay seperate from Master
until my changes are ready to be merged.
What's the right workflow for this or is there even one?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
子模块中的分支与父存储库中的分支完全分开。
在父存储库上创建
NewFeature
功能分支并不意味着您必须在子模块中创建相同的功能分支。这仅意味着您的父存储库将引用
NewFeature
分支中该子模块的新提交。子模块提交可以在任何分支中进行(仅在子模块中定义)。话虽这么说,最好还是在子存储库中创建一个
NewFeature
,以建立某种命名约定,使您能够在父存储库和子模块之间找到高度耦合的提交集。(另外,如问题“Git 子模块:指定分支/标签”,子模块本身首先总是处于分离的 HEAD 模式)
Branches in a submodules are completely separate from branches from the parent repo.
Creating a
NewFeature
feature branch on your parent repo doesn't mean you have to create the same in the submodule.It only means that your parent repo will reference new commits from that submodule in the
NewFeature
branch. The submodule commits can have been made in any branch (only defined in the submodule).That being said, it is probably best to create also a
NewFeature
in the subrepo, to establish some kind of naming convention enabling you to find highly coupled set of commits between your parent repo and your submodule.(plus, as illustrated in the question "Git submodules: Specify a branch/tag", a submodule per se is always at first in a detached HEAD mode)