Your destination for complete Tech news

Git

How to rename git branch local and remote

528 0
< 1 min read

If you want to rename a local branch even if you have already pushed it to remote, follow the following steps.

Rename your local branch
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

Delete the old remote branch and push the new local branch with new name

  • git push origin :old_name new_name

Reset the upstream branch for the new name local branch

  • git push origin -u new_name

Leave A Reply

Your email address will not be published.

10 − seven =

This site uses Akismet to reduce spam. Learn how your comment data is processed.