3

Sometimes I forget to push a git submodule. Is there a way to show which git submodules are ahead of origin, that have not been pushed?

adrelanos
  • 1,453
  • 2
  • 16
  • 27

1 Answers1

4

A simple status on each submodules could give you a good representation of their respective state:

git submodule foreach "git status || true"

See "Use git submodule foreach with function" for more sophisticated scripts to run in combination of a git submodule foreach command.

That will show push status only if:

  • your module is configured to follow a branch. (Otherwise, a submodule is checked out as a detached head, and the commit status would be empty, the push status non-existent)

    git config -f .gitmodules submodule.<path>.branch <branch>
    git submodule update --init --remote
    
  • a branch has been checked out (and commits done)

    cd asubmodule
    git checkout master
    # add and commit
    

(See "Git submodule is in “detached head” state after cloning and submodule update")

Then the command would work (for instance for the 'compose' submodule of the project b2d):

VonC@voncvb MINGW64 /c/Users/VonC/prog/b2d (master)
$ git submodule foreach "git status || true"
Entering 'compose'
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
nothing to commit, working directory clean
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • @adrelanos It will show push status (I just tested it), but my answers lacked the necessary steps for that push status to be visible. I have amended my answer. – VonC Apr 29 '15 at 13:03