2017-07-14 104 views
0

使用GitPython,我试图列出给定提交(即当前目录的“快照”)的目录内容。使用GitPython列出特定git提交的目录的内容

在终端,我会做的是:

git ls-tree --name-only 4b645551aa82ec55d1794d0bae039dd28e6c5704 

我如何可以做同样的GitPyhon?

根据我对类似问题的发现(GitPython get tree and blob object by sha)我试过递归遍历base_commit.tree及其.trees,但我似乎没有得到任何地方。

任何想法?

回答

0

我找不到比实际调用execute更优雅的方式。 这是最终的结果:

configFiles = repo.git.execute(
    ['git', 'ls-tree', '--name-only', commit.hexsha, path]).split() 

其中commitgit.Commit对象,path是我感兴趣的路径

相关问题