Migration of remote
In your cloned repository:
- Switch to "master" branch:
git checkout master
- Rename the "master" branch to "main" by running:
git branch -m master main
- Push new "main" branch to remote by running:
git push -u origin main
- If "master" was the default branch (often
develop
acts as the default branch): In the GitHub project settings, change the default branch from "master" to "main" - Cleanup old "master" branch by running:
git push origin --delete master
Note: You might change your protected branches
Migration for cloned repositories
Other people then either re-clone the repository from scratch or:
- Switch to the "master" branch by running:
git checkout master
- Rename the "master" branch to "main" by running:
git branch -m master main
- Fetch latest from remote by running:
git fetch
- Remove tracking of remote "master" branch by running:
git branch --unset-upstream
- Add tracking of remove "main" branch by running:
git branch -u origin/main
Notes
Make sure to:
- Update CI / CD pipelines to work with new main branch