

In this case, we are already on the “ feature” branch, so we do not need to switch to any other branches. In the below examples, we are going to rename one of our branches currently named “feature”.įirst of all, we are going to check on which branch we are at the moment with the “ git branch” command. Look at the following syntax for the Git rename branch command: git branch -m Examples on Git Rename Branch “old” is the name of the branch you want to rename and “new” is the new name for the branch. For renaming a branch, the command that should run is git branch -m. The git branch command allows you to change a branch.
#Rename branch git how to
In order to illustrate this method, let’s observe a quick example from the below modules.Īlso Read: How To Change Git Remote Origin Git Rename Branch $ git push : įinally, you have to set the upstream branch for the newly created branch using the “git upstream” command. To achieve that, you have to use the “ git push” command and specify the old branch name as well as the new branch name. If you want your changes to be available on the remote side, you have to push your branch to the remote. It is important to mention that this command changes the name of your local branch. Note: Before changing the branch name, make sure to switch to the branch that you want to rename. # Optional command (if you are not on the target branch) Next, you just have to specify the name of the new branch. In order to change a branch name on Git, you have to use the “git branch” command followed by the “-m” option. So, check out the available stuff regarding Git Rename Branch from here. This guide will help you rename git branches locally and remotely. How To Clean Up Git Branches | Git Clean Up Local and Remote Branches.How To Switch Branch on Git | What is Git Switch? | Git Switch vs Checkout.How To Create a Git Branch | Learn Git Create New Branch from Current Branch.If you want to change your git branch names then take a look at the entire tutorial on How do you Change Branch Name on Git easily. Renaming the branch name in Git is very simple using the related git commands. Choosing the branch name will always depend upon what you are working on. At some times, developers may think to change the branch names in git for pushing the changes in that specific branch. Git Branches are mainly used for the development of the main project smoothly and in a decided workflow.
