Sometimes I want to change the name of a branch, both locally and remotely.
For example, I may want to change the name of the branch from master to main.
This article will show you how to do that.
First, locally, rename the branch from master to main.
git branch -m master main
You can also set the main branch as the default branch.
Then delete the master branch in the remote.
git push origin :master
Finally, the local main branch follows the remote main branch.
git push --set-upstream origin main