$ git clone <repo> $ cd <repo>
$ git branch -m master main
git branch's official documentation says:
-Moption, will be renamed to . If had a corresponding reflog, it is renamed to match , and a reflog entry is created to remember the branch renaming. If exists, -M must be used to force the rename to happen.
Optionally, it's able to check the result with
$ git status On branch main Your branch is up to date with 'origin/master'. nothing to commit, working tree clean
Push the change.
$ git push -u origin main
With Web browser, visit github or gitea, and show settings page.
Then, switch "Default branch" from master to main.
Delete old branch if it has become unnecessary.
$ git push origin --delete master