首页 > 解决方案 > git push --recurse-submodules=check 推送到远程,即使有子模块在他们的远程之前

问题描述

我有以下文件夹结构

-outerRepo
  -innerRepo
  -innerRepo2
  -innerRepo3

其中innerRepo,innerRepo2innerRepo3是子模块。

当我运行时,git submodule foreach git status我得到以下输出

Entering 'innerRepo'
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   stuff.html

Entering 'innerRepo2'
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 tree clean
Entering 'innerRepo3'
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 tree clean

据我所知,在git push --recurse-submodules=check里面运行outerRepo 不应该推送任何东西,因为如图git submodule foreach git status所示,有一些子模块提交在其远程中不可用。我应该首先推送子模块中的提交。但是,当我更改内部文件outerRepo并提交它时,git push --recurse-submodules=check仍然会将文件推送到远程。这怎么可能?我正在跑步git version 2.30.1.windows.1

标签: gitgit-submodules

解决方案


推荐阅读