I have the following project setup:
Solution AProject 1(a lightweight component)Project 2(contains a lot of files and depends onProject 1)
Solution A is a single git repository. Then I created another solution and found that I could reuse and even update the functionality of Project 1. So my second solution would probably look like this:
Solution BProject 1(must be shared!)Project 3(depends onProject 1).
Now I want Project 1 to become a shared component. That is, every time I change the source code of Project 1 from either solution (A or B), I need the other one to update accordingly.
Maybe this has something to do the the submodule feature of git. However, the only way I was able to use it is to specify the whole Solution A as a submodule for Solution B. This is not really what I want ideally due to enormous size of Solution A. I only need a tiny part of it to be a submodule.
I know that it’s possible in svn and works exactly as I’ve described: you specify a directory within an external repository in the svn:externals property.
Any tips on that? Or maybe, I’m missing something?
This is definitely related to submodules (see the nature of submodules)
In your case, the ideal solution would be to extract
Project1fromSolutionAGit repo:See How to extract a git subdirectory and make a submodule out of it?.
But that involves rewriting SolutionA history, which is a problem if you have already published it and if some people are pulling from it.
Using filter-branch for the extraction process.
Then declare
Project1as a submodule inSolutionB: