# Git rename branch on remote

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.

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

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

```bash
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.
