通过 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"
}