version-control - git rename remote branch only - How do I rename a local Git branch?

git rename master branch / git / git-branch

I don't want to rename a remote branch, as described in Rename master branch for both local and remote Git repositories.

Sazzad Hissain Khan



Answer #1

If you are on the branch you want to rename:

git branch -m new-name

If you are on a different branch:

git branch -m old-name new-name

2. Delete the old-name remote branch and push the new-name local branch

git push origin :old-name new-name

3. Reset the upstream branch for the new-name local branch

git push origin -u new-name