Git Default Branches: from master to main

Short Form

$ cd old_repository
$ git branch -m master main
$ git push -u origin main

$ ssh my_hosting_provider
my_hosting_provider$ cd code_repos/my_bare_repo.git
my_hosting_provider$ git symbolic-ref HEAD refs/heads/main

my_hosting_provider$ exit
$ git push origin --delete master

Background

I'm still finding old git repositories created when master was the default branch name. It's easy to update these cloned repos to use the modern default branch name, main:

$ cd old_repository
$ git branch -m master main
$ git push -u origin main

The part I can never remember is, how do I update the origin repository to make main its default branch, and to delete its old master branch?

A web search shows how to do this for repositories hosted, on, e.g., github. But I keep a few repositories on a web hosting provider, managing them with ssh. How to update these bare repositories?

With thanks to StackOverflow user Philipp Leitl:

$ ssh my_hosting_provider
my_hosting_provider$ cd code_repos/my_bare_repo.git
my_hosting_provider$ git symbolic-ref HEAD refs/heads/main

Once that is done, back on my local machine I can finally delete the origin master branch:

my_hosting_provider$ exit
$ git push origin --delete master