Git is the most popular distributed version control and source code management system. In addition, Git was designed and developed by Linus Torvalds for Linux kernel development.
In this quick guide we will show you how to rename a local and a remote Git branches. If you have a remote Git branch you can’t directly rename it, you need to push the renamed local Git branch and delete the Git branch with the old name. However, follow the steps below to rename a Local and Remote Git Branch:
01- Start by switching to the local branch which you want to rename:
$ git checkout
02- Now, you should rename the local branch by typing:
$ git branch -m
At this point, you have renamed the local branch. If you’ve already pushed the
03- Push the
$ git push origin -u
04- Delete the
$ git push origin --delete
Conclusion
how to rename a branch in git
That’s it. You have successfully learned how to rename a local branch or a remote branch in Git branch. You might want to check the following guides: