1

I have this project structure:

root | +-- SHARE +-- Project1 +-- Project2 +-- Project3 

All projects reference the project SHARE.

So I created 4 repos one in each folder. Then I tried to add SHARE as a submodule to Project1, but I don't get what I want, because Git copied all source files from SHARE to Project1\SHARE. I wan't the submodule SHARE to checkout the files to the folder SHARE, which is parallel to Project1.

Is it possible to reference SHARE as a submodule for Project1 without copying the source files from SHARE? Or is there a better way to tell the repo for Project1 that it depends on repo SHARE?

I'm using Windows7 with VS2010 and Git Extensions.

2 Answers 2

1

The point of submodules is that the version of the main repository determines the version of a submodule. If you don't need this feature, you probably do not need to mess with submodules at all.

Now, if this feature is desired, then your structure doesn't make sense, as different Projects might need different versions of SHARE. That's why it is suggested that SHARE is copied into every repository, so they do not clash trying to get versions of SHARE they want.

Sign up to request clarification or add additional context in comments.

3 Comments

This structure is used in our company since many years with a relativly large code base and many projects. But we didn't use source control so far. I now try to adapt this structure to git repositories. There are many developers who put code into SHARE and when a project is compiled, we always have the latest source. What we lack is the feature to revert to an old code base (other than backup) when we find some errors. I see your point and if this doesn't make sense with git, I will use seperate repos without submodules.
@Michael: But what if you want to build an older version of Project1, and the current SHARE is incompatible?
Yes, you are right, we can't do this at the moment. We have to work with backups. But with seperate Git repos we can check out the old project and the SHARE with the same date. This should be possible to handle. Better would be, if a submodule wouldn't have to be under the same folder as the main project, but unfortunatly this seems not to be possible with Git.
0

If all of your projects can reference the same SHA1 of SHARE, and would all benefit from any modification you would do in SHARE, then you should declare all 4 directories (3 Projects, 1 SHARE) as submodule within root, which would be a parent repository.

But that also mean that Project1 alone wouldn't have any record of what exact version of SHARE it needs.
So your structure only make sense if all 3 Projects are tightly coupled (you cannot work on one without having to work on the other two).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.