2

I have a project with lots of submodules for some specific reason. I just want to know which branches exist for each submodule. I know that I could initialize each submodule with

git submodule update --init

and perform a

git ls-remote --heads {URL} 

on each submodule to get the currently existing branches of that submodule (git branch -r also lists already deleted branches). But since our project exists of many submodules the initialization above needs a lot of time on the first run. Is there a way to get the existing branches without initializing the submodules?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
heinkunibert
  • 361
  • 2
  • 5
  • 15

1 Answers1

3

As mentioned in "List submodules in a git repository", you could get the url directly from the .gitmodules file.

grep url .gitmodules | sed 's/.*= //'

Once you have extracted the url, you can do the git ls-remote --heads {URL} without having to initialize the submodules.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250