简体   繁体   中英

How to get a list of git submodules of repository before `git clone`?

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?

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…

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM