• 0

How to rename a remote branch in git

If for some reason you pushed your branch upstream but want to change the name of that branch, you can easily accomplish this by a simple set of git commands. However keep in mind that you should do this only if nobody else has pulled from the branch that you are going to rename. Unless you wish to make enemies that is.

  • First rename it locally
  • Push your new branch to the remote
  • Delete the old remote branch
git branch -m old-branch-name new-branch-name
git push origin new-branch-name
git push origin :old-branch-name