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.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git checkout <old-branch-name>
git checkout <old-branch-name>
git checkout <old-branch-name>
2. Rename that branch.
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
git branch -m <new-branch-name>
git branch -m <new-branch-name>
git branch -m <new-branch-name>
3. Push the new branch and delete the old one from the remote server.
There can be cases where you want to revert a branch or commits in git but due to many other commits on the top of it, Github does not show revert button for branch/commits or does not allow to revert due to other commits on the top of it. (The…
It's difficult to know the name of the current active GIT branch in the terminal so let's see how to do configuration to show active Git Branch name in Terminal. Run below command in terminal to open the file. sudo vim ~/.bash_profile Add below code and save the file. #…
This post is useful to those who are maintaining multiple branches on multiple servers and merge production branch or any specific branch to all other branches once something gets updated to production branch or the specific branch. For example: If you have a multiple server with its respective branches and you…