Git submodule status - how to show current branches in submodules

You can run git submodule status --recursive.

It gives

  • commit id
  • path of the submodule in the project
  • branch name

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