将子模块添加到存储库

Adding submodules to a repository

我在 git.I 我的存储库 (/path/myrepo) 上添加了另一个存储库作为子模块,我在 Windows 上使用 git 扩展。添加存储库后,我提交的唯一文件是

[submodule "comms"]
    path = comms
    url = http://xxx-eng1/stash/scm/ta/sub.git

存储库在我的 /path/myrepo 中。我应该提交这个子模块并将其推送到我的主模块中吗?

是的,你应该。 .gitmodules 文件与其他文件一样受版本控制,如 .gitignore 文件。它还与项目的其余部分一起推拉。

你可以$ git diff --cached --submodule更清楚

当您提交这些更改时,您会看到如下消息 create mode 160000 comms

160000 模式是 Git 中的一种特殊模式,这意味着您将提交记录为目录条目而不是子目录或文件