【发布时间】:2015-07-07 14:17:24
【问题描述】:
有时我忘记推送一个 git 子模块。有没有办法显示哪些 git 子模块在原点之前,没有被推送?
【问题讨论】:
标签: git push git-submodules git-push
有时我忘记推送一个 git 子模块。有没有办法显示哪些 git 子模块在原点之前,没有被推送?
【问题讨论】:
标签: git push git-submodules git-push
每个子模块的简单状态可以很好地表示它们各自的状态:
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
(见“Git submodule is in “detached head” state after cloning and submodule update”)
然后该命令将起作用(例如'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
【讨论】: