有时候我忘了推一个git子模块。有没有办法显示哪些git子模块在原点之前,尚未被推送?
答案 0 :(得分:4)
每个子模块的简单状态可以很好地表示各自的状态:
git submodule foreach "git status || true"
参见" Use git submodule foreach
with function"使更复杂的脚本与git submodule foreach
命令组合运行。
仅在以下情况下显示推送状态:
your module is configured to follow a branch。 (否则,子模块将作为分离头检出,并且提交状态为空,推送状态不存在)
git config -f .gitmodules submodule.<path>.branch <branch>
git submodule update --init --remote
已检出分支(并已完成提交)
cd asubmodule
git checkout master
# add and commit
(参见&#34; Git submodule is in “detached head” state after cloning and submodule update&#34;)
然后该命令将起作用(例如对于'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