如何从 Github 存储库中获取并列出所有文件

How to Get And List All files from a Github Repository

我正在尝试列出 Github 存储库中的所有文件。

def listFiles(self, filepath):
    git = githubHandler(GH_USERNAME, GH_PASSWORD)
    gh, repo, branch = git.connect_to_github()        
    tree = branch.commit.commit.tree.recurse()
    print repo.blob
    print branch

到目前为止我只能输出repo 分支和名称。 有什么想法吗?

所以我折腾了半天是这样解决的:

def list_filenames(self, filepath):
    git = githubHandler(GH_USERNAME, GH_PASSWORD)
    gh, repo, branch = git.connect_to_github()        
    tree = branch.commit.commit.tree.recurse()
    for filename in tree.tree: 
        print("[*] Found file {0}".format(filename.path)) 
        print filename.path
    return None