Search code examples
gitintellij-idea

Change default remote git branch in IntelliJ


For some reason, my local dev branch is my default release branch. Is there any way in the IntelliJ UI to change this?

enter image description here

For clarification, by "default" I mean the default for that branch, not for all branches. The default for all branches is supposed the branch name itself. I do not know how my dev's default got changed.


Solution

  • No GUI way to do it in IntelliJ 2021.2.3, though it's been a feature request for 3 years. If interested, add your vote to IDEA-197078 at IntelliJ.

    To set a new default remote branch (also called the upstream branch), open the project and checkout the branch whose default you want to change. Then open the IntelliJ terminal and type: git branch -u <remote>/<branch>.

    The -u stands for upstream, which is more explicit in the Git for Windows command:

    git branch --set-upstream-to <remote>/<branch>.

    For example, if the remote is projectA and you want dev1 to be the new default remote branch, then type: git branch -u projectA/dev1

    More info about branches here from the official online reference guide Pro Git (a great resource!).