相关问题:How do I find the default branch for a repository using the Github v3 API
与的相关问题不同,我要列出默认分支的文件。
我知道列出master分支文件的API是:
https://api.github.com/repos/owner/repo_name/git/trees/master但是,默认的分支名称可以是main。
是否可以仅通过一个查询列出默认分支的文件?
发布于 2022-03-25 08:26:42
您可以简单地使用HEAD (它指的是默认的远程分支)。
之后,我使用了gh api (gh auth login)
gh api repos/owner/repo_name/git/trees/HEAD示例:
gh api repos/VonC/gitcred/git/trees/HEAD --jq ".tree[].path"https://stackoverflow.com/questions/71613933
复制相似问题