Git has been changing the naming convention of the default branch from the name master
to main
.
The first step is to rename the local branch:
$ git branch -m master main
Check the status of the repository:
$ git status
On branch main
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Now we push the new branch to the remote:
$ git push -u origin main
Now before we can delete the old master
branch, we might need to change the default branch of the remote repository to the new main
branch. After that’s done, we can delete the old branch:
$ git push origin --delete master