You mention google repo tools. Here's a solution by repo
.
Say you have two repositories, parent.git
and sub.git
, hosted in https://hostingservice
. The expected folder structure is
parent/
├── .git
└── sub/
└── .git
As sub
is not a submodule of parent
, you need to add it to parent
's .gitignore.
Create a repository to track repo manifests. Suppose it's https://hostingservice/manifest.git
. Make a manifest foo.xml
that organizes parent.git
and sub.git
.
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote fetch=".." name="origin"/>
<default remote="origin"/>
<project name="parent" path="parent" revision="release_v1.2" />
<project name="sub" path="parent/sub" revision="release_v0.3" />
</manifest>
Add and commit foo.xml
in manifest.git
and suppose it's on branch default
.
Now you can use repo
to download parent.git
and sub.git
,
# initialize the current folder as a repo environment
repo init -u https://hostingservice/manifest.git -b default -m foo.xml
# clone the repositories and check out their revisions
repo sync -c -d
repo init
clones manifest.git
and checks out default
into .repo/manifests
.
foo.xml
instructs repo
to clone parent.git
and checks out its branch release_v1.2
into the folder parent
under the current directory, and clone sub.git
and checks out its branch release_v0.3
into parent/sub
.
revision="release_v0.3"
means to always use the current head of release_v0.3
whenever you re-run repo init
and repo sync
commands. Sometimes you may want a specific commit 8b6228f4e0f5b059a6d5d93ba9aed15089c4b324
reachable from release_v0.3
, then use revision="8b6228f4e0f5b059a6d5d93ba9aed15089c4b324" upstream="release_v0.3"
instead to get a fixed revision.
When needed you can add more repositories to foo.xml
.
` or similar, depending on what language you use to write the script. Given that there are manys, the script probably should maintain a mini-database or log file of which s have been successfully updated, and which have yet to be updated.
– torek Aug 27 '21 at 11:17