How to rename local and remote git branch?
This blog will help you to rename a local git repository branch and also, you can apply the same changes on the remote git repository.
Rename Local Git Branch
You can use -m
option to rename a git branch.
To rename the active branch
$ git branch -m <new_branch_name>
To rename other branch
To rename other branch than active one, first define the name of the old branch name followed by the new branch name.
$ git branch -m <old_branch_name> <new_branch_name>
Update changes to remote
Now, if you have already pushed the old branch to the remote. You can point a new branch to a new remote.
$ git push origin :<old_branch_name>
$ git push origin <new_branch_name>:refs/heads/<new_branch_name>