Git 项目根目录的状态显示子模块更改,但在子模块中,none 可用
Git status from project root shows submodule changes, but in submodule, none are available
从我项目的根目录来看,子模块似乎显示了要提交的更改。但是,当我更改到该目录时,没有等待任何更改。我该如何解释?
注意到子模块的更改是从子模块的根而不是项目的根添加、提交和推送的。或许有什么困惑?
$ 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 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