如何使用Github v3 API查找存储库的默认分支 [英] How do I find the default branch for a repository using the Github v3 API

查看:53
本文介绍了如何使用Github v3 API查找存储库的默认分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

My goal is to get the tree for the latest SHA in the default branch

GET /repos/:owner/:repo/git/trees/:sha

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

How do I find the lastest SHA from the default branch?

我知道我可以打电话

GET /repos/:owner/:repo/branches/:branch

但是我不能只使用"master"作为分支,因为不是所有的回购都使用master作为默认分支.

But I can't just use "master" for the branch as not all repos use master as the default branch.

我如何确定回购协议的默认分支是什么?

How do I find out what the default branch for a repo is?

推荐答案

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

Make a call to /repos/:owner/:repo and read the default_branch property value - this is the name of the default branch. See example response here: http://developer.github.com/v3/repos/#get

这篇关于如何使用Github v3 API查找存储库的默认分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆