如何在 gitpython 中使用 git 子模块 foreach 的变量

How to use variables of git submodule foreach in gitpython

使用 gitpython, I would like to use repo.git.submodule('foreach', …) and get the variables available such as name, sm_path, displaypath, sha1 and toplevel as defined in the git documentation.

我找不到任何关于 gitpython 的文档,我对 API 的理解是有限的。

感谢 stsewd reply 在 Github 问题上,应该写

repo = git.Repo('foo/bar')
for sub in repo.submodules:
    pass

和文档:https://gitpython.readthedocs.io/en/stable/reference.html#git.repo.base.Repo.submodules