
In the Branches popup or in the Branches pane of the Git tool window, select the branch you want to rename and choose Rename. In the Log view, select the commit that you want to act as a starting point for the new branch and choose New Branch from the context menu. In the Branches popup or in the Branches pane of the Git tool window select a local or a remote branch that you want to start a new branch from and choose New Branch from Selected. The new branch will start from the current branch HEAD. In the dialog that opens, specify the branch name, and make sure the Checkout branch option is selected if you want to switch to that branch. In the Branches popup, choose New Branch or right-click the current branch in the Branches pane of the Git tool window and choose New Branch from 'branch name'.


To hide non-favorite branches, click Show Only Favorites at the bottom of the Branches popup.Ĭreate new branch Create a new branch from current branch You can also select a branch in the Branches pane of the Git tool window and click on the toolbar. To mark a branch as a favorite, in the Branches popup, hover the mouse cursor over the branch name, and click the star outline that appears on the left: Favorite branches are always displayed at the top of the Branches popup and in the Branches pane of the Git tool window. The main branch is marked as a favorite by default. If you have many branches, you may want to see only your favorite ones. You can also manage branches and perform batch operations with multiple branches in the Branches pane of the Git tool window. In IntelliJ IDEA, all operations with branches are performed in the Git Branches popup: To invoke it, click the Git widget in the Status bar (it shows the name of the branch that is currently checked out):
#GIT RENAME REMOTE BRANCH HOW TO#
You now know how to rename a local git branch and how to rename the git master branch to main using the git branch -m command.In Git, branching is a powerful mechanism that allows you to diverge from the main development line, for example, when you need to work on a feature, or freeze a certain state of a code base for a release, and so on. I normally keep all branch names lowercase to avoid causing confusing issues when trying to find a branch, and use hyphens to make the names readable. It’s also worth noting that branch names are case sensitive. Please note there is only 1 dash before the ‘m’ and 2 dashes before the ‘move’. And -m and –move do exactly the same thing. What is the -m flag in this command? : git branch -m branch-name-now new-branch-name This is exactly the same as: git branch -move branch-name-now new-branch-name What are Git branch -m and –move … which renames the branch which is called branch-name-now to new-branch-name. The first line uses this generic command form: git branch -m branch-name-now new-branch-name The first line renames the local master branch to main, the second line pushes new main branch to the remote repo. If you want to rename your master branch to main then run this git command: git branch -m master main

Some git systems still name the initial git branch master but it’s pretty common in other systems for the initial branch to be called main, which is my preference. You can see in the image above that I am still on main, there are still 3 other branches, but we now have a branch called new-branch-name instead of branch-name-now. Now use the git branch command to list your local branches again. This means ‘please rename the branch which is called branch-name-now to new-branch-name‘. Putting all of this together you can use this command to rename a local git branch : git branch -m branch-name-now new-branch-name You will also have to specify the name of the branch you want to rename and the name you want to rename it to. To rename a local git branch you need to use the git branch -m command. You can also see that there are 3 other branches, one of which is called branch-name-now. In the list you can see in the image above that we are currently on the main branch, as it’s highlighted in green and has an asterisk next to it. How to Git rename master branch to mainīefore we start renaming any branches get a list of your branches using the git branch command with no flags, as shown here:.Use git branch to see local branch names.
