Shallow submodule clone


I have a project with submodules that have a deep history. Is it possible to perform a shallow clone of the submodules?

The depht option doesn’t seem to be applied to submodules.

I am not aware of any way to specify shallow depth using the git clone plugin. This means you would need to use a custom plugin, or manually take control of cloning submodules. The below example show an example of how you could do the latter.

    image: plugins/clone
+   recursive: false
    image: docker:git
+     - git config -f .gitmodules submodule.<name>.shallow true
+     - git submodule update --init --recursive


If my .gitmodules has the shallow option set to true, will il be used by the default clone step?

I am not sure, since I personally do not have much experience using submodules. You can have a look at the git clone plugin to test out its behavior.

Note that you can test the plugin in isolation, directly from the command line