Git submodule status - how to show current branches in submodules
Asked Answered
U

2

16

Checking status of submodules in main repository with this command:

git submodule status

produces output (without clear information about branches):

491e03096e2234dab9a9533da714fb6eff5dcaa7 vendor/submodule1 (v1.51.0-560-g491e030)
8bccab48338219e73c3118ad71c8c98fbd32a4be vendor/submodule2 (v1.32.0-516-g8bccab4)

Is it possible to check current branches on submodules without:

cd vendor/submodule1
git status
cd ../submodule2
git status

?

This command don't work:

git submodule status -b
Unsteady answered 27/1, 2016 at 11:58 Comment(0)
U
33

Answer was hidden in git submodule foreach:

git submodule foreach 'git status'

You can always make it simpler by assign this to alias:

git config --global alias.sb "submodule foreach \"git status\""

Now git sb give you nice information about your branches in submodules:

Entering 'vendor/submodule1'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Entering 'vendor/submodule2'
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
Unsteady answered 27/1, 2016 at 19:22 Comment(0)
P
13

You can run git submodule status --recursive.

It gives

  • commit id
  • path of the submodule in the project
  • branch name
Pumpernickel answered 20/4, 2020 at 8:52 Comment(1)
I don't think this displays the branch the submodule is onDeplore

© 2022 - 2024 — McMap. All rights reserved.