I have a local branch master
that points to a remote branch origin/regacy
(oops, typo!).
How do I rename the remote branch to origin/legacy
or origin/master
?
I tried:
git remote rename regacy legacy
But this gave an error:
error : Could not rename config section 'remote.regacy' to 'remote.legacy'
Best Answer
There are a few ways to accomplish that:
Renaming local and remote
Renaming Only remote branch
Credit: ptim
Important note:
When you use the
git branch -m
(move), Git is also updating your tracking branch with the new name.git remote rename
is trying to update your remote section in your configuration file. It will rename the remote with the given name to the new name, but in your case, it did not find any, so the renaming failed.But it will not do what you think; it will rename your local configuration remote name and not the remote branch.
Note Git servers might allow you to rename Git branches using the web interface or external programs (like Sourcetree, etc.), but you have to keep in mind that in Git all the work is done locally, so it's recommended to use the above commands to the work.