项目根目录中的 Git 状态显示子模块更改,但在子模块中,没有可用

TekiusFanatical

从我的项目的根目录来看,子模块似乎显示了要提交的更改。但是,当我更改到该目录时,没有任何更改在等待。我该如何解释?

请注意,子模块的更改是从子模块的根而不是项目的根添加、提交和推送的。也许存在混淆?

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   path/to/submodule (new commits)

no changes added to commit (use "git add" and/or "git commit -a")

$ cd path/to/submodule

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

$ git submodule status
+bdaa5b15120853ab8c3b502733e7337e825c51a1 path/to/submodule(heads/master)
博士

Git 子模块的工作方式如下。在具有子模块的项目中,超级项目会记住每个子模块的当前提交。如果子模块发生变化(有新的提交),超级项目会注意到这一点。你应该让超级项目记住这些新的提交:

# from the top of the superproject
git add path/to/submodule
git commit -m "Update submodule"

或者干脆

git commit -m "Update submodule" path/to/submodule

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章