Renaming git branch

If there is a need to rename a git branch follow these steps:

Renaming local branch

Renaming a current branch:

 git branch -m new_name

If you are on a different branch:

 git branch -m old_name new_name

Push to remote

git push origin new_name

or if you don’t want to type name of new branch (git can obtain the branch name itself):

git push origin HEAD

Delete old remote branch (optional)

In case old branch is already on remote, you will need to delete it:

git push origin :old_name