Git rename branch

Git rename branch

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.


References


About the Author

Sandeep Agrawal
working @ Kalpavruksh Technologies as Software Engineer. I am a simple and straightforward person adaptable to any environment and work culture. Like to work in a creative and challenging environment using cutting edge technologies where I could constantly learn and successfully deliver solutions to problems.

Be the first to comment on "Git rename branch"

Leave a comment

Your email address will not be published.


*


1 Shares
Tweet
Pin1
Share
Share
Share
%d bloggers like this: