2017-07-14 54 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是我感興趣的路徑

相關問題