I was looking at this explanation on the use of Submodules within GIT (also, in my case, I am using Gitlab to store code and not github).
I was reviewing instructions mentioned here: LINK 1: Working With Submodules
I was looking at this item as well: LINK 2: Gitlab Submodules
In LINK 1, it seemed to say that that the Main Repository (Parent) and Sub Repository (Submodule) are just regular repositories within the Git system.
In the picture below, I would like (as an example) to have forks of each repository (for development, testing and production).
Each level would be (for the Parent : TEST is a FORK of PROD, DEVL is a FORK of TEST):
testme.com:DEVL/restapi-field.git
testme.com:TEST/restapi-field.git
testme.com:PROD/restapi-field.git
Each level would be (for the Submodule: TEST is a FORK of PROD, DEVL is a FORK of TEST ):
testme.com:DEVL/submoduleOne.git
testme.com:TEST/submoduleOne.git
testme.com:PROD/submoduleOne.git
According to LINK 2, one should use a file called .gitmodules
The thing is, .gitmodules would be defined differently in the parent (based upon the group it is in). Again, see picture.
How could one implement this?
I have seen some cases where one would just define all files needed (example):
.gitmodules.development
.gitmodules.test
.gitmodules.production
and then each level (i.e. development, test, production) would work with the file that was most applicable to it.
Jenkins is also being used in this scenario. Should I make the following job in Jenkins whereby:
- Jenkins pulls down the correct Parent repository (either development, testing or production)
- Copy the correct corresponding
.gitmodulesinto the repository ( ex: cp .gitmodules.development /.gitmodules ) - Run an Update to get the most recent versions (i.e. something like)
- git submodule sync --recursive
- git submodule update --init --recursive
- Contiue processing with the code (i.e. compiling it, creating a lib, etc.)
Any other options that one could consider?
TIA
