Branch names should be cheap. To rename the branch you're currently on:
git branch -m new-name
To rename a different branch:
git branch -m old-name new-name
If the old name was already pushed, you also need to:
- Push the new name:
git push origin -u new-name
- Delete the old name from the remote:
git push origin --delete old-name
- Tell collaborators to do the same locally.
Renaming the default branch (master → main) is the same dance plus a GitHub setting change to flip the default branch on the remote.