How to list the URL for all Git submodules?
Asked Answered
K

3

12

The "git remote get-url origin" can be used to fetch the location of the remote. How do I do the same for all the submodules?

Klepht answered 29/9, 2020 at 15:18 Comment(0)
S
13

Run the command for every submodule:

git submodule foreach --recursive git remote get-url origin
Selfloading answered 29/9, 2020 at 15:47 Comment(0)
V
4

For a different approach which also illistrates how to get the URL of a single named submodule:

for submodule in $(git submodule | awk '{ print $2 }' | xargs)
do
  git config --file=.gitmodules submodule.${submodule}.url
done
Vaclava answered 10/2, 2023 at 8:44 Comment(0)
S
3

this works without git submodule update --init

git config --file .gitmodules --get-regexp '\.url$' | awk '{print $2}'

based on List submodules in a Git repository

Steamship answered 1/2, 2023 at 15:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.