项目根目录中的Git状态显示子模块的更改,但在子模块中,没有可用状态 [英] Git status from project root shows submodule changes, but in submodule, none are available
本文介绍了项目根目录中的Git状态显示子模块的更改,但在子模块中,没有可用状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
从我的项目根开始,该子模块似乎显示了要提交的更改。但是,当我切换到该目录时,没有等待任何更改。我如何解释这一点?
请注意,来自子模块的更改是从子模块的根而不是项目的根添加、提交和推送的。也许这就是困惑所在?
$ 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
这篇关于项目根目录中的Git状态显示子模块的更改,但在子模块中,没有可用状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文