通过API调用设置GitHub默认分支 [英] Set GitHub default branch through API call

查看:151
本文介绍了通过API调用设置GitHub默认分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个除master分支以外的分支dev.还需要使用GITHUB API将dev设置为默认分支.

I need to create a branch dev which is other than master branch. Also need to set dev as default branch using GITHUB API.

如果有人知道以编程方式调用哪个API或执行该API的方式,请分享详细信息.我知道可以通过Web UI来完成,但是我正在寻找一种不涉及人工干预的解决方案.

Please share details if anyone know which API to call or a way to do it, programmatically. I know that it can be done through the Web UI, however I am looking for a solution that does not involve manual intervention.

推荐答案

我没有足够的声誉来回答以上亚当的评论,但问题是name是必填字段. JSON实际上应该是:

I don't have enough reputation to reply to the Adam's comment above but the problem is name is a required field. The JSON should actually be:

PATCH /repos/:owner/:repo
{
"name":":repo"
"default_branch": "dev"
}

这篇关于通过API调用设置GitHub默认分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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