如何使用Github v3 API找到存储库的默认分支

Dan*_*ore 9 github-api

我的目标是在默认分支中获取最新SHA的树

GET /repos/:owner/:repo/git/trees/:sha
Run Code Online (Sandbox Code Playgroud)

如何从默认分支中找到最新的SHA?

我知道我可以打电话

GET /repos/:owner/:repo/branches/:branch
Run Code Online (Sandbox Code Playgroud)

但我不能只为分支使用"master",因为并非所有repos都使用master作为默认分支.

如何找出回购的默认分支是什么?

Iva*_*zak 17

调用/repos/:owner/:repo并读取default_branch属性值 - 这是默认分支的名称.请参阅此处的示例响应:http://developer.github.com/v3/repos/#get

  • `master_branch`仅用于向后兼容.`default_branch`将替换[下一版API]中的`master_branch`(http://developer.github.com/#expected-changes). (2认同)