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 local checkout of project A or B should contain L as sub-directory, like:
A
+-- .idea (project metadata)
+-- src
+-- L
+-- src
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?