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?
Asked
Active
Viewed 758 times
1 Answers
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
-
@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