Rename Git Branch
This is something I occasionally have to do and I usually get it wrong. So, for my reference, the next time I need it.
Rename the old branch and push the new one.
git rename -m master main git push origin main
Change the default branch on the server. This can be done in the repository settings, if you are using Gitea or Github. If you use Gitolite, you need to log on the server and edit the
HEADfile, changing the main reference to the new name:
$ cd repo.git $ cat HEAD ref: refs/heads/main
(Solution found on StackOverflow.)
Push the deletion of the old branch.
git push -u origin main git push -d main