This may be terrible, I am not sure.
Let us say we have a repo "product" with a working directory
/product
/product/command.script
/product/config/ (bare git repo)
And a repo "config" with a working directory
/config
/config/config.json
The command.script file has actions to interact with a bare repo. ex. Running command.script BRANCH1 would run the command
git show BRANCH1:config.json
Is there any way that the "/product/config/" folder can be a submodule of the "product" repo, such that when the "product" repo is cloned the "config" repo will also be cloned
git clone --bare [config origin here] config
from its origin and when the "product" repo is fetched, the "/product/config" submodule can be fetched
git fetch origin '*:*'
Or is this something that should be handled through hooks of some sort?
No: when the repo "product" is fetched, its index will include a gitlink (special entry recording the SHA1 of the submodule).
That entry can only be used in a non-bare repo, in order to be expended as a nested (submodule) repo.
That is why the git clone
man page mentions:
--recursive
--recurse-submodules
After the clone is created, initialize all submodules within, using their default settings. This is equivalent to running
git submodule update --init --recursive
immediately after the clone is finished.
This option is ignored if the cloned repository does not have a worktree/checkout (i.e. if any of--no-checkout/-n
,--bare
, or--mirror
is given)
That means it is best for the config
repo to be cloned separately (even bare) at the right SHA1 (the one recorded by the gitlink in the first product
repo), and for the git show BRANCH1:config.json
to be executed in that other cloned repo (with git -C
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With