Change default branch for new projects

We use development for our default branch in most of our projects, but sonarcloud assumes it’s supposed to be master, which means we have to manually switch that for each project we create. Is there a way to set that automatically?

4 Likes

If you are on GitHub or Bitbucket Cloud, SonarCloud will automatically set the correct default branch when you setup your project from the web interface (when you select the repositories to analyze).
If you are on Azure DevOps, then this can’t be automated for now.

Got it! I realized this was only the case for projects we had manually added. Using the analyze tool has solved this.

1 Like

Hi @Fabrice_Bellingard

What about existing projects on GitHub?
Our repo’s main branch was master when we connected SonarCloud.
Later on we switched default branch to develop, however SonarCloud still consider master to be a main branch.

Is there any way to manually set or trigger the change for default branch?

Hi @vladimir_abr

It’s currently not possible to “select” which branch is the default one. However, you can rename your default branch to whatever you want. For instance, you can rename “master” to “develop”.

@Fabrice_Bellingard, can you elaborate on this, does renaming the default branch change the default branch? Because renaming the default branch doesn’t seem to do anything.

Most of our default branches are “master” but we want to have “develop” analyzed so I’ve tried setting develop as a long lived branch and renamed the default branch to “develop” but that doesn’t trigger an analysis when I make a commit to the “develop” branch.

1 Like