Unable to change default branch

This is an odd one - I don’t seem to be able to change the default branch from master to root, which is what we’d like to use for our repos given the move away from master as the default branch name.

I found this topic from 2019, but this doesn’t seem to work even with the correct API calls. GH’s direct contact support is busy and I haven’t gotten a reply yet, so I was wondering if anyone else has run into this. Here’s what happens:

Via the API (using the hub CLI tool)

  1. hub api repos/<org>/<repo> -X PATCH -F name="<repo>" -F default_branch="root"
  2. Note that the JSON that has been output contains: "default_branch": "root"
  3. hub api repos/<org>/<repo> -X GET -F name="<repo>"
  4. Note that the JSON that has been output contains: "default_branch": "master"

Via the Web UI

  1. Head to the Branches section of your repo settings and update the default branch to root
  2. Note the confirmation near the top of the page stating that the Default branch changed to root
  3. Reload the Branches section of the repo settings or head to the Code tab and note that the default branch is still master

I’m mostly wondering if this is unique to our org, or other people are running into this one.

For added context:

  • We do not have any branch protection rules set
  • We are working with public open-source projects only
  • We’ve noticed this with normal repos, template repos, and repos created from template repos

:wave: hello there @gdude2002, and welcome to the GitHub Support Community! :tada:

Thanks for sharing those steps here. I attempted to reproduce this as described, but I see that the update propagated. Below is a motion picture of this in action: I’m wondering if you’re still seeing this behavior?

While I can’t speak to the hub CLI tool, I successfully updated the branch and confirmed it was updated by running the following curl requests:

# Change the default branch
curl --verbose \
  -H "Authorization: token $PERSONAL_ACCESS_TOKEN" \
  -X PATCH \
  -d '{"default_branch":"root"}' \

# Confirm the default branch was changed
curl --verbose \
  -H "Authorization: token $PERSONAL_ACCESS_TOKEN" \

I’m wondering if you’re able to reproduce this on a public repository using these curl commands (while changing the appropriate owner and repository name values)? Sharing that would help us investigate further! :male_detective: