1. Verify the local branch has the correct name:
git branch -a
2. Next, delete the branch with the old name on the remote repository:
git push origin ––delete old-name
3. Finally, push the branch with the correct name, and reset the upstream branch:
git push origin –u new-name
Alternatively, you can overwrite the remote branch with a single command:
git push origin :old-name new-name
Resetting the upstream branch is still required:
git push origin –u new-name
# creates a branch called some_branch
# switches to this newly created branch
# pulls changes from the origin remote branch
git checkout -b some_branch origin/some_branch
git fetch
git reset --hard origin/{{branch}}
# replace {{branch}} with name
git branch branch_name --set-upstream-to your_new_remote/branch_name
Delete your local branch: git branch -d local_branch
Fetch the latest remote branch: git fetch origin remote_branch
Rebuild the local branch based on the remote one: git checkout -b local_branch origin/remote_branch
git branch branch_name -u your_new_remote/branch_name