Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git submodule status - how to show current branches in submodules

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
like image 279
Everettss Avatar asked Jan 27 '16 11:01

Everettss


2 Answers

You can run git submodule status --recursive.

It gives

  • commit id
  • path of the submodule in the project
  • branch name
like image 138
Krishna Avatar answered Oct 07 '22 21:10

Krishna


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
like image 26
Everettss Avatar answered Oct 07 '22 21:10

Everettss