wilded
4/24/2019 - 8:59 AM

Renaming a remote branch in Git

  1. Start by switching to the local branch which you want to rename:
    git checkout <old_name>

  2. Rename the local branch by typing: git branch -m <new_name>

  3. If you’ve already pushed the <old_name> branch to the remote repository delete the <old_name> remote branch: git push origin --delete <old_name>

  4. Finally push the <new_name> local branch and reset the upstream branch: git push origin -u <new_name>