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:

1 Like

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

This problem is not fixed!!! I changed the default branch to master but now the default branch is random between the two every time I refresh the page. Same randomness happened on Code and Settings tabs!

Just so you’re aware, I worked with GH support via email and the problem turned out to be a Probot config issue — someone had actually configured Probot to reset the branch.

So, if you’re using Probot or some other GH bot/application, it’s always good to check those!

I have the same problem, not using Probot. For some reason default branch was develop, trying to change it to master and it just won’t happen.

Note that I imported the repo from a different account, and the visibility was private in the old account and it is public in the current account. Also note that the default branch in the first account was master–I don’t know why it became develop, nor why changing it doesn’t work.

Hi there @ChessDigits :wave:

That’s unfortunate to hear that you’re still unable to modify your default branch name! Presumably, you’re updating this via the API. You do also have the option to change via the UI:

…but if you’re failing to update via API, perhaps you could provide the output of a curl -v which should reveal what isn’t working properly.

If you do share this output, please be sure to obscure any sensitive data (like a PAT that might be used for API access) when you post.


I don’t know what you mean with the API. I’m changing it directly from the GitHub website­ (repo > settings > branches). Now that being said it does look like it caught on, thought it does happen sometimes it’ll still show develop… Seriously there seems to be a bug with this feature. Anyway, no need to reply anymore, you do what you want with the feedback.

Hi @ChessDigits !

I mention the API, because the OP for this thread is about updating the default branch specifically via our API and not via the UI.

Edit: the primary focus of this thread is about behavior relating to the API, and outdated experiences from the UI that should no longer occur.

Perhaps we should get a new thread started in the GitHub Help How to Use Git and GitHub board.

Though I’m also happy to accept your feedback, but I’m not quite sure what’s failing so far. Would you mind sharing screenshots of the flow in the UI? If any errors are elevated, seeing those errors in the dev console from the browser would be interesting!

As an aside, I went back over my personal repositories that were still named master and I updated them to main via the UI without any issue. Here’s an example I modified earlier, before I replied to your post.