How to rename a remote branch in git

If for some rea­son you pushed your branch upstream but want to change the name of that branch, you can eas­ily accom­plish this by a sim­ple set of git com­mands. How­ever 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 ene­mies 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

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *