How to rename Git Branch Name with Git Command?

Spread the love

Do you want to learn How to rename Git Branch Name with Git Command? In this article, I will show you how to rename a branch in Git using a simple command. This is useful if you want to give your branch a more descriptive or meaningful name. You will also see how to check the current branch name and how to update the branch name in GitHub. Let’s get started!

Clone Git Repository (Optional):

If you are new to Git and GitHub, you may need to create or clone a repository first.

Rename Git Branch using Git Command:

First, let’s see how to check the current branch name. You can use the “git branch” command to list all the branches in your repository and see which one is active.

Also Read: How to integrate LINKEDIN LOGIN in Laravel 10

Run the following command:

git branch

Now, let’s say you want to change the branch name from “dev” to “dev-change“.

You can use the “git branch -m” command to do that.

The syntax is:

git branch -m <new-name>

For example, run this command:

Also Read: How to remove a column from a table in Laravel migration?

git branch -m dev-change

You can also verify that the new branch name is updated in GitHub by going to the repository page and clicking on the “Branches” tab:

That’s it! You have successfully changed the branch name in Git using a simple command.

Also Read: How to Remove Public From URL in Laravel 10

I hope this article was helpful for you. 🙂

Leave a Comment