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"}' \
  "https://api.github.com/repos/francisfuzz/change-default-branch" 

# Confirm the default branch was changed
curl --verbose \
  -H "Authorization: token $PERSONAL_ACCESS_TOKEN" \
  "https://api.github.com/repos/francisfuzz/change-default-branch"

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:

Apologies for not responding for so long - I didn’t get an email for some reason.

I am still noticing this behaviour. An example of a repository I’m seeing it on is this one from the Kotlin-Discord org. This is a public repository, and it’s the repository I tested on in my original post.

Thanks for following up @gdude2002! No worries on the timing :v:

  • If you try to change the default branch to root from the Settings tab, what does the UI show? An image or a GIF would help me get a better idea of what’s happening here.
  • Could you try reproducing this on a new repository and let me know if you’re able to reproduce the same behavior there?

Depending on your input, we’ll take the next steps from there :+1:

Thanks for your quick response!

Of course, Murphy’s law - as soon as I try to record, it works. Genuinely unbelievable, haha.

Do you know if anyone looked into this in the interim and changed anything? I guess it’s going to be difficult to provide extra info when I can no longer reproduce, but at least it works I guess.

@gdude2002 - I’m so glad to hear that it works now! :sparkles: While I can’t speak to any one specific change, it’s definitely possible that one of our engineering teams deployed an update between your original post and now. :rocket:

If you’re seeing any other instances of this in the future, please open a new topic with steps to reproduce the behavior and we’ll do our best to help. :v:

1 Like