How to rename a Git branch

Supposedly you have misspell your branch name "my_nise_branch" and you want to rename it to "my_nice_branch"

 

Rename the branch locally

$ git branch -m my_nise_branch my_nice_branch

In case your branch is already pushed remotely you should delete and push the new branch remotely

Delete the old branch

$ git push origin :my_nise_branch

Push the new branch to remote and track it

$ git push --set-upstream origin my_nice_branch

 

********************************** ************************* ************************ **************** ****************** *********** ************** ************* ************ *************