Skip to main content

Git rename branch on remote

Published 1 min readMarkdown

It's impossible ... but, you can copy a branch then delete the old one.

On the remote named origin (the default name), copy the master branch in new main branch.

git push origin origin/master:refs/heads/main

To delete the old master branch (the : means delete)

git push origin :master

FYI: the :master part, from the second command, can be put at the end of the first command to have a one line command.

About the author

  • 10+ years most with Ruby on Rails and JavaScript frontend and some Go. My first language is C for 3 years in university.

No comments yet. Be the first to comment.

More from this blog