Renaming a Git branch local+remote

Rename your local branch

  • When you have the target branch checked out locally

git branch -m desired_name

  • When you do not have the target branch checked out locally

git branch -m wrong_name desired_name

Delete the wrong_named remote branch and push the desired_name local branch

git push origin :wrong_named desired_name

Reset the upstream branch for the new-name local branch, checkout the new desired_name branch

git push origin -u desired_name