【发布时间】:2016-02-13 15:57:11
【问题描述】:
我正在尝试使用 GitHub API 来获取指定存储库 (owner/repo) 的默认分支。
我没有找到任何关于此的文档。要获取我使用的所有分支:
curl https://api.github.com/repos/owner/owner/branches
这会输出以下 json:
[
{
"name": "docs",
"commit": {
"sha": "a3...",
"url": "https://api.github.com/repos/owner/repo/commits/a3..."
}
},
{
"name": "master",
"commit": {
"sha": "8c...",
"url": "https://api.github.com/repos/owner/repo/commits/8c..."
}
}
]
这已经很有用了,因为在我的例子中,默认分支是master(如果存在)或gh-pages。但是我仍然想知道获取 GitHub 存储库默认分支的正确方法是什么。
【问题讨论】:
标签: git github github-api