Skip to main content

Command Palette

Search for a command to run...

Git rename branch on remote

Updated
1 min read
T

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

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.

More from this blog

Thomas Brennetot

21 posts

10+ years experienced software engineer living in Tokyo.