git submodule…

ADD SUBMODULE

in the directory in which you want the repo to be
linked into, run

git submodule add 

to remove or update
 at present using these commands
you will get the default branch HEAD commit

----

RESET OR DELETE

edit .gitmudules and remove the entry
edit .git/config and remove the submodule entry
run
git rm —r cached 
run
rm -rf .git/modules/path\_to\_submodule

----

UPDATE SUBMODULE

cd into the submodule
git pull pulls in the latest code
checkout a different branch, do whatever - update it as a repo
then outside of that
git add -A
git commit
git push
this updates the parent repo pointer and brings in the correct code going forward

so it’s a pointer to a repo and actual detached commit from the parent view, a repo within the module…

----
JENKINS

**jenkins pipeline template will need changing to add in the submodule behaviors…**

also for a local copy you need:
git clone --recurse-submodules 
to pull the code as part of the checkout

so there’s that

 

We can maintain code in a repo ansible_role-jenkins-base-agent, and, say, ansible_role-jenkins-docker-agent, and then in a build for jenkins-docker-build-agent-ami, layer the base + docker roles and have a docker agent ami. Code maintained in a single place, used in multiple locations.

— doug