Reputation:
It's possible with git submodules to checkout multiple repositories as submodules into respective paths, e.g.:
% git submodule add git@.../repo1.git ./here/is/1
% git submodule add git@.../repo2.git ./here/is/2
But what if I need to checkout the contents of repo1
and repo2
both into a single path, ./here/is/3
?
Basically I have a metric shit-ton of submodule repos I need to all be checked out into a very rigid directory hierarchy on the client side when the user does git clone --recursive ...
I want the contents of all submodules to be checked out into ./somepath
. Can it be done?
One thing I considered was using symlinks, but that feels wrong.
EDIT:
I want the contents of 1
and 2
in the above to be placed in the same target directory on the client. I can do this by having the user manually run a script after cloning (it is not possible to have git track a single file), but it seems like there should be a cleaner way to do this -- manually creating a symlink for each submodule is a lot of work, and it seems like the submodule abstraction should be able to handle this.
Maybe my question is a dupe-in-disguise?
Upvotes: 1
Views: 270
Reputation: 1324178
One way would be to create another parent repo, with the submodules declared directly in it:
newParentRepo/
1/
2/
3/
...
That parent repo could be cloned --recursive in ./somepath
, and the submodules would be directly under ./somepath
(in their respective root directories 1/
, 2/
, ...).
You would need to synchronize the SHA1 of the submodules as recorded by the first parent repo into the second parent repo, in order for said second repo to record the right list of submodules SHA1.
Upvotes: 1