Can I update the Main branch from "master" to "main" without deleting the main branch?

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) - sonarqube v9.9LTS (DE)
  • how is SonarQube deployed: zip, Docker, Helm - zip
  • what are you trying to achieve - updating main branch from master to main
  • what have you tried so far to achieve this

Hi team,
we have few bitbucket repositories where the main branch is “main” and not “master” and integrated with sonar.

from sonar UI we are seeing below where the main branch is associated with master. Is there a way we can switch the main branch in sonarqube from ‘master’ to ‘main’ without deleting ‘main’ branch? please assist.

Regards!
Dev

Hi Dev,

If you’re talking about renaming the current “master” branch to “main”, that option is tucked under the cog menu on the main branch row in your screenshot.

If you’re talking about demoting “master” and promoting “main”, that’s not possible. Yet!

We’re working on it, but it’s an architecturally significant change, so it’ll take a couple more versions to deliver. We lay (some of) the groundwork in 10.0, E.T.A. Monday.

 
HTH,
Ann

Thanks Ann,

I have tried using that option to rename and as you can see from the attached screenshot there is a branch with name ‘main’ already exists hence its not allowing to rename ‘master’ branch as ‘main’.

If we delete the main branch does it clear existing scan records for PRs/branches under main branch?
if not - we can delete main and rename ‘master’ as ‘main’.
if yes - Is there a way we can switch the main branch in sonarqube from ‘master’ to ‘main’ without
losing existing scan records under ‘main’.

Regards!
Dev

Hi Dev,

Yeah, I failed to say that if main already exists, you won’t be able to rename master over it.

So the question here is what your goal is.

Are both branches equally valid and up to date - and representing the same source code? Then just delete the current main, rename master and you’re good.

But if there’s a difference in the content and the branch currently named main is the right one… well, you’re kinda stuck until we get the functionality in place on our side.

 
HTH,
Ann

thanks for confirming!