如何将文件添加到 git 子模块?

How can I add a file to a git submodule?

我想从我作为子模块添加到我的存储库的存储库中制作一个 Python 包。有没有办法将 __init__.py 文件添加到此子模块并在父存储库中跟踪它?

如果您在该子模块存储库中添加任何文件,您将必须:

  • 从那个子模块仓库添加、提交和推送(假设你有权推送到它的上游仓库。如果没有,你需要change the remote url of that submodule by one representing a fork that you own
  • 返回父仓库,添加、提交并推送:父仓库将添加新的子模块 SHA1(其树的新状态)。 SHA1 被称为 gitlink (a special entry in the parent repo index)