Renaming an existing branch in git repository is easy and simple. This method applies to renaming a branch in your local repository. Changes will reflect in the remote repository after you make a push.
If you are in the branch that you need to rename
git branch -m <new_branch_name>
If you are not in the branch that you need to rename
git branch -m <branch_you_want_to_rename> <new_name>
Note : Please remember, once you rename a branch, the branch with old name exists and a new branch with new name is also created. So please remember to delete the old branch from remote once renamed branch is created after the push.
Follow steps :
1. Switch to the branch you want to rename, then rename it it locally:
git checkout old_branch git branch -m old_branch new_branch
2. Remove old branch from remote repository:
git push origin :old_branch
3. Push the renamed local branch to remote repository:
git push origin new_branch