2

I'm trying to get a submodule list of a repo before preforming clone.

And then to choose which submodule repo to clone.

Is there any way to do it?

Tomer.Epstein
  • 269
  • 1
  • 3
  • 10

1 Answers1

2

If you want to review the list of submodules of the first level without cloning the superproject download file .gitmodules from the superproject. You can use git archive:

git archive --format=tar --remote=$ORIGIN_URL HEAD -- .gitmodules | tar -O -xf -

As submodules could be recursive you have to repeat this for every submodule found in the downloaded .gitmodules.

After that you can clone any submodule's repository manually.

You may also want to review the list of submodules after cloning the superproject. First, clone without submodules:

git clone $ORIGIN_URL # Don't use `--recursive`
cd <repo_dir>
git submodule init
cat .gitmodules
git submodule update submodule1 submodule2…
phd
  • 82,685
  • 13
  • 120
  • 165
  • So, I understand that there's no way doing this in one git command without downloading .gitmodules with third app? – Tomer.Epstein Jan 03 '19 at 13:22
  • 1
    For non-recursive submodules the first command (`git archive`) could be considered *one command*. But not for recursive submodules. – phd Jan 03 '19 at 13:35