The Easiest way to rename GIT branch

rename GIT branch

My Lovely Techies, there is good news for you. Today we are going to enlighten you about the two easiest ways where you can git rename branches. When you are working on a project it can be frustrating when the project does not get completed, since you cannot rename a branch. Today we are going to provide an easy gateway to do so.

Method 1: Changing through GIT checkout

First, fire up your computer and then go to the root terminal and change the directory. The change directory command is CD. For instance, if you want to find a project on your desktop then the change directory command would be

cd Desktop/project-name

Once you find the branch that you to rename, all you need to do is perform a Git checkout command and that would look like

 git checkout branch-name

Now using the command – m, change the the name of the branch

git branch -m new-branch-name

So if a developer wants to change the branch name from test 1 branch to test 2 branch, then he types the following code

git branch -m test-branch2

Method 2: Changing without Git checkout

First, you need to fire up the computer and then see that you are in the master branch. If you are not on the master branch then you need to run the command Git checkout master or Git checkout main which would help you find the master branch

Once you find the branch use the command -m using the syntax

git branch -m old-branch new-branch

Now to rename a branch room from test branch one to test branch two add the following

git branch -m test-branch test-branch2

Takeaway

We have shown you a quick and easy way to navigate to the git rename branch. Following this simple trick, you will find it super easy to delete a page appearing in the middle of the document or at the end of the document. If you liked what you witnessed, show us some love by staying connected with our daily newsletter and sharing this article with people who are in need.

Post Comment

You May Have Missed