GitPython子模块树显示
我正在使用一个git repo,它下面有多个子模块。我能够毫无问题地遍历该文件夹中的blob和tree,但是当我遇到子模块时,我收到以下错误:AttributeError:如果子模块最初未设置,则无法检索该子模块的名称 我使用的代码如下所示:GitPython子模块树显示,python,git,gitpython,Python,Git,Gitpython,我正在使用一个git repo,它下面有多个子模块。我能够毫无问题地遍历该文件夹中的blob和tree,但是当我遇到子模块时,我收到以下错误:AttributeError:如果子模块最初未设置,则无法检索该子模块的名称 我使用的代码如下所示: from git import Repo repo = Repo("repo_name") origin = repo.remotes[0] ref = origin.refs[0] tree = ref.commit.tree['devices'] &
from git import Repo
repo = Repo("repo_name")
origin = repo.remotes[0]
ref = origin.refs[0]
tree = ref.commit.tree['devices'] <- devices is a submodule
print tree.name
来自git导入回购的
回购=回购(“回购名称”)
origin=repo.remotes[0]
ref=原点。refs[0]
tree=ref.commit.tree['devices']