I have a group of projects/modules that are related enough that i want them in the same repository but they live accross multiple directories locally on my machine. Is there a way I can add them as sub directories in a remote repository?
this is how i would normally add a remote
git remote add origin ssh://[email protected]:2227/usr/local/git_root/foo_project.git
would something like this work
git remote add origin ssh://[email protected]:2227/usr/local/git_root/foo_project.git/A
git submodule add ssh://[email protected]:2227/module1 module1/
You would do it the other way around. Git repositories are very cheap, so you usually create a new repository for each subproject if they are not directly dependent on each other. This also makes for a cleaner history as when one is working on project A, he does not get involved with all the changes that happened in project B.
So, you would maybe do it like this:
ssh://[email protected]:2227/usr/local/git_root/foo_project/a.git ssh://[email protected]:2227/usr/local/git_root/foo_project/b.git
If you have one “master” project that should link them all, then submodules are a good choice. You would set up the master project and add a submodule for each subproject. That way you would have the complete project contained in the master project but would still be able to work independently on the subprojects.