如何将 git submodule 更新到当前 master 或其他分支?

假设你在 MySubmodule 目录中有一个 git submodule。如果你对 MySubmodule 引用的仓库进行了更改,你可能想更新你的项目以引用最新的提交。

为此,只需转到 MySubmodule 目录并在那里运行 git pull。你也可以 git checkout 任何其他分支。

之后,你需要在外部仓库中提交更改(即 git submodule 当前引用的提交)。

外部仓库中的 git status 将显示如下更改:

git-submodule-status.txt
Changes not staged for commit:
    (使用 "git add <file>..." 更新要提交的内容)
    (使用 "git checkout -- <file>..." 丢弃工作目录中的更改)

                已修改:   MySubmodule (新提交)

正常使用 git add MySubmodulegit commit,或使用 git commit -a 提交所有暂存的更改。


Check out similar posts by category: Git, Version Management