If you had named a git branch incorrectly and had pushed the branch to remote repository. Follow the steps listed below to rename the remote branch:
- Rename the local branch.
If you are on the branch then,
git branch -m <new-name>
If you are not on the branch then,
git branch -m <old-name> <new-name>
- Delete the old named remote branch and push new named local branch
git push origin :<old-name> <new-name>
On success, this text will be displayed.
* [new branch] ->
- Reset upstream branch for the local branch.
git push origin -u <new-name>
Branch <new-name> set up to track remote branch from origin.