How to Rename Git Branch Locally and Remotely
# Rename branches locally
git branch -m <old_branch> <new_branch>
# Delete the old branch on remote
git push <remote> :<old_branch>
# Push the new branch to remote
git push -u <remote> <new_branch>
Example
# Rename branches locally
git branch -m master main
# Delete the old branch on remote
git push origin :master
# Push the new branch to remote
git push -u origin main