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

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

问题描述

我需要创建一个 dev 分支,它不是 master 分支.还需要使用 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 或以编程方式调用的方法,请分享详细信息.我知道它可以通过 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.

推荐答案

我没有足够的声誉来回复上面 Adam 的评论,但问题是 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天全站免登陆