Git rename branch local and remote

1. Rename your local branch

If you are on the branch you want to rename

1
  git branch -m new-name

If you are on a different branch

1
  git branch -m old-name new-name

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

1
  git push origin :old-name new-name

3. Rebase any other branches that were based on the old-name branch

1
  git rebase --onto new-name old-name <other_branch>

4. Update your remote’s tracking information

1
  git remote set-branches origin '*'
1
  git fetch

5. Done!

Join my newsletter

If you want to receive my latest essays and interesting finds subscribe to my list: