How to change the main branch in SonarQube

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube ID information
    Server ID: 28C70C56-AX-pmK9qinZ6_e5CzYgQ
    Date: 2023-05-30

  • how is SonarQube deployed: zip, Docker, Helm
    Docker or Helm, not sure

  • what are you trying to achieve
    Change the main branch for projects in SonarQube

  • what have you tried so far to achieve this
    Go to Project Settings > Branches & Pull Requests
    Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

@cathy If i am correct you wont be able to change the main branch in SonarQube. What you can do is update the main branch name to the branch name you need.

follow the below steps to change the branch name:

Go to the project β†’ Select Project settings β†’ Select Branches and pull request β†’ select the gear icon near to the main branch β†’ Click rename branch

1 Like

Hi Sebastian,

Thanks for the response. When I tried to rename the branch to another branch, I got below error saying the branch name already exists in the project.


@cathy that’s expected only because you already analyzed the branch name you want to make as default
jest delete the branch and try renaming it will work. after renaming scan the code again and you will be able to see it as default branch.