Make some submodules optional in git
Asked Answered
A

1

8

We have a git repo that is serving multiple projects/targets. In addition there are 3 submodules for separately developed modules that are referenced and pulled into the workspace.

Are are going to have a 4th repo for a module that will be needed only for a specific project and only specific engineers have permissions to access it. Is there any way to make this 4th submodule optional or it's all-or-nothing?

Thanks a lot,

Guy.

Aye answered 17/5, 2018 at 14:54 Comment(4)
How would an "optional" submodule differ from a "not-optional" one? What behaviour would be different in your idea?Algonquin
Few alternatives can work for me (and maybe more that I'm missing): * By default an optional submodule won't be cloned, but will have to be explicitly "enabled", or the other way around - there will be a way to mask it. * If the user doesn't have permissions for an optional submodule, the overall recursive operation won't fail, but maybe there will be just a warning printed.Aye
I'll rephrase my question: What is an "optional submodule" and what would be the difference to a "normal" one? What, in your opinion makes a submodule optional or not optional?Algonquin
I will clarify my clarification - I'm looking for a way to avoid a failure of the overall recursive operations when a user doesn't have permissions to (or just doesn't need) a submoduleAye
N
1

You can use something like following in your .gitmodules:

[submodule "secrets"]
    path = secrets
    url = ./secrets

Then, after checkout, you can clone the optional repositories like:

rm -rf secrets
git clone git://... secrets
Nebulose answered 27/5, 2019 at 20:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.