I just renamed my local branch using
git branch -m oldname newname
but this only renames the local version of the branch. How can I rename
In my case, I needed an additional command,
git branch --unset-upstream
to get my renamed branch to push up to origin newname.
(For ease of typing), I first git checkout oldname.
Then run the following:
git branch -m newname git push origin :oldname
*or*git push origin --delete oldname
git branch --unset-upstream
git push -u origin newname or git push origin newname
This extra step may only be necessary because I (tend to) set up remote tracking on my branches via git push -u origin oldname. This way, when I have oldname checked out, I subsequently only need to type git push rather than git push origin oldname.
If I do not use the command git branch --unset-upstream before git push origin newbranch, git re-creates oldbranch and pushes newbranch to origin oldbranch -- defeating my intent.