How do I switch branches from master to main?

Issue

A GIT repository uses the master branch and needs to be switched to main.

Resolution

To switch the default branch used to deploy apps from master to main, first create a new branch locally:

git checkout -b main

Next, delete the old default branch locally:

git branch -D master

From there, the local environment only knows about the main branch.

Reset the GIT repository hosted on the Heroku Platform using the heroku-reset command from the heroku-repo CLI plugin. Doing so will not impact the running application. (Note: Please communicate this change with your team. If you are working with other developers who are not aware of the reset, they might push to "master" which will overwrite the reset).

Re-deploy the application using the new default branch:

git push heroku main

To switch the default branch in GitHub, please refer to this article: https://docs.github.com/en/github/administering-a-repository/setting-the-default-branch

Ask on Stack Overflow

Engage with a community of passionate experts to get the answers you need

Ask on Stack Overflow

Heroku Support

Create a support ticket and our support experts will get back to you

Contact Heroku Support