Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GitPython子模块树显示_Python_Git_Gitpython - Fatal编程技术网

GitPython子模块树显示

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'] &

我正在使用一个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'] <- devices is a submodule

print tree.name
来自git导入回购的

回购=回购(“回购名称”)
origin=repo.remotes[0]
ref=原点。refs[0]
tree=ref.commit.tree['devices']