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
This article shows how to do it real easy.
To rename a local Git branch, we can use the Git branch -m command to modify the name:
git branch -m feature1 feature2
If you’re just looking for the command to rename a remote Git branch, this is it:
git push -u origin feature2:feature3
Check that you have no tags on the branch before you do this. You can do that with git tag
.
Here is what worked for me:
Create the new branch first:
git push github newname :refs/heads/newname
On the GitHub site, go to settings and change the Default branch to newname
Delete the oldname
git push github --delete oldname
The following commands worked for me:
git push origin :old-name-of-branch-on-github
git branch -m old-name-of-branch-on-github new-name-for-branch-you-want
git push origin new-name-for-branch-you-want