This will rename the remote branch to new-branch-name and set it to track the local new-branch-name branch. Hence, keep the new one and delete the old branch from the remote repository. Letâs say the remote repository name is XYZ and you want to push the locally renamed branch to it git push -u xyz new-Linux-h2sĪfter that, you will see both new and old branches in your remote repository. However, here we are actually pushing the locally renamed branch to the remote repository and then deleting the old branch from there. This will change the name of the branch you are viewing to the new name you. Whereas, for those who are interested in renaming the remote GIT branch as well on the remote repository then instead of the git branch command and -m option we will use the git push command with the -u option to update the remote branch. To rename a Git branch, run the following command: git branch -m . Running the above command syntax with your actual GIT branch name will only rename the branch available on your local system and does not affect the branch on the remote repository. Renaming Git Branch Start by switching to the local branch which you want to rename: git checkout Rename the local branch by typing.git branch -m old-Linux-h2s new-Linux-h2s Now, the command syntax for this will be. We can use this command to rename the branch in case we have named it wrongly or just want to change it for some other project.įor example, your old git branch name is old-Linux-h2s and now you want to change it to some new name letâs say new-Linux-h2s. It is easily possible to rename the existing local branch of GIT using the command- git branch and option -m on our system. Have you ever come across a situation where you want to rename a Git branch If yes then this article will help you with that.
0 Comments
Leave a Reply. |