parm530
5/10/2019 - 3:26 PM

Renaming a pushed branch

On the branch (LOCALLY)

  • git branch -m new-name

On a different branch

  • git branch -m old-name new-name

If branch is already pushed (REMOTELY)

  • Delete the old branch
    • git push origin :old-name new-name
  • Switch into the branch if not already in, to reset the upstream branch
    • git push origin -u new-name
  • Push the <new_name> local branch and reset the upstream branch:
    • git push origin -u <new_name>
  • Delete the <old_name> remote branch:
    • git push origin --delete <old_name>