Add recursively git repos in subfolder as submodules:
iam looking for a solution to add git repositories as submodules to a folder which is a git repo.
I already have the folder structure and the cloned repositories in the destination folder. All i need is to automate adding those repos in the subfolders as submodules.
there are hundreds of git repos so i want to automate it.
structure: folder 1 & 2 serve as categories.
~/gitrepo-main/folder1/folder01/submodule
~/gitrepo-main/folder1/folder02/submodule
~/gitrepo-main/folder2/folder01/submodule
~/gitrepo-main/folder2/folder02/submodule
EDIT:
probably found the solution via Convert git repo to submodule
script run from gitrepo-main folder
#!/bin/bash
for d in `find folder1/ -maxdepth 3 -mindepth 3 -type d`
do
pushd $d
export url=$(git config --get remote.origin.url)
popd
git submodule add $url $d
done