How do I reference part of the code of another git project in a git project?

I know that using git"s subtree can reference another project B as a subdirectory in one project A, but will reference the entire project B, and I only want to reference some of the code in B.

the application scenario is that among several web systems, one system needs to refer to the database models definition of other systems, while other systems have a large amount of code, so using subtree to reference the whole project will result in a large volume of code. So I would like to ask how to solve this situation with git?

if you don"t use git, are there any other better solutions? (of course, you can"t copy the code file Synchronize manually)

Mar.01,2021

split Project B into multiple sub-modules. I think this may be the more likely way.

Menu