In this article, we will learn how to rename a git branch in local and for the remote servers.
If you ever faced a situation where you created a new branch, pushed your change to the remote repository, and then realized that you wrongly named your branch then you can very easily correct that using a git command.
Let’s see how to do that.
How to rename branch
For this, you just need the following command to rename your git branch name.
1. Checkout to the branch that you want to rename.
git checkout <old-branch-name>
2. Rename that branch.
git branch -m <new-branch-name>
3. Push the new branch and delete the old one from the remote server.
git push origin -u <new-branch-name> git push origin --delete <old-branch-name>
That is it. You have successfully changed your Git branch name.
I hope you like this article and helps you to solve your problems.
Visit Techtalkbook to find more related topics.