I need to create a branch dev
which is other than master
branch. Also need to set dev
as default branch using GITHUB API.
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.
On GitHub.com, navigate to the main page of the repository. Under your repository name, click Settings . In the "Code and automation" section of the sidebar, click Branches. Under "Default branch", to the right of the default branch name, click . Use the drop-down, then click a branch name.
We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the new Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API pages. The branches API allows you to modify branches and their protection settings.
In the "Code and automation" section of the sidebar, click Branches. Under "Default branch", to the right of the default branch name, click . Use the drop-down, then click a branch name. Click Update . Read the warning, then click I understand, update the default branch.
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"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With