Git Rename Branch : local & remote


If you have named a branch incorrectly and pushed this to the remote repository follow these steps to rename the branch name both locally and on server.

1. Rename your local git branch.
If you already have branch checked out which you want to rename

git branch -m newName</code>

If you are on a different branch

git branch -m oldName newName


2. Delete the old-name remote branch and push the new-name local branch


git push origin :oldName newName

3. Reset the upstream branch for the new-name local branch.
Switch to the branch and then:

git push origin -u newName