futurenero.blogg.se

Git rename local branch
Git rename local branch




git rename local branch

git rename local branch

git branch -m bugfixįatal: A branch named 'bugfix' already exists. We will get an error if we rename the feature branch to bugfix. git branch -m master main # currently on feature branch Duplicate Names in Gitīy default, Git will block the renaming operation if the new branch name is not unique, i.e., the branch name already exists in our repository.įor example, consider we have a branch with the name bugfix. git branch -m įor example, if we are on the feature branch and want to rename the master branch to main, then we will run the following command. We can rename a branch while checked-out on a different one by passing the current or existing branch name along with the new name. Renaming a Branch from Another Branch in Git Or we can use the code discussed in the next section. git checkout master # moving from feature to master branch For example, if we are on the feature branch and want to rename the master branch to main, then we will run the commands shown below. If we wish to rename a different branch, we can first check out that branch(using git checkout) and then use the above command. git branch -m įor example, if we are on the master branch and want to rename it to main, we will run the following command. Use the git branch command with the -m flag to rename the currently checked-out branch.

#GIT RENAME LOCAL BRANCH HOW TO#

Let's learn how to rename a local branch in Git. We can use the git branch command to rename a branch. For example, the bugfix branch name suggests that some bug or error has been solved on that branch. The branch name must be relevant to the work performed on it. Last Updated: July 1st, 2022 How to Rename a Local Git Branch?Ī branch is a simple pointer to a commit.






Git rename local branch