共享库的Git monorepo布局 [英] Git monorepo layout with shared library
问题描述
我们有两个项目 A
和 B
,它们具有共享库 L
.为了避免重复 L
的历史,我们正在考虑建立一个包含 A
, B
和 L的Git monorepo.
在顶级:
We have two projects A
and B
with shared library L
. To avoid duplication of L
' s history, we are considering to set up a Git monorepo which will contain A
, B
and L
on the top-level:
/
+-- L
| +-- src
|
+-- A
| +-- .idea (project metadata)
| +-- src
|
+-- B
+-- .idea (project metadata)
+-- src
项目 A
或 B
的本地签出应包含 L
作为子目录,例如:
A local checkout of project A
or B
should contain L
as sub-directory, like:
A
+-- .idea (project metadata)
+-- src
+-- L
+-- src
使用Git和稀疏签出或任何其他Git功能是否有可能?如果不是,是否有一种备用存储库布局,该布局不会重复 L
并仍然提供上述工作树结构?
Is this possible with Git and sparse checkouts or any other Git functionality? If not, is there an alternative repository layout which does not duplicate L
and still gives above working tree structure?
推荐答案
There's actually another way to do it - you can add your library to both repositories as an X-Module. It's a free server-side tool aimed to avoid the disadvantages of Git Submodules. You won't need to create a monorepo - the library stays in a separate repository, synced with a directory in each of the projects. As it's server-side, for the end-users A and B will be just regular repositories with a directory "L" in each of them; but any changes, made to "L" in A or B (or directly on the "L" repository) will be automatically fetched to the other two.
这篇关于共享库的Git monorepo布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!