- Create main branch off of up-to-date master:
git checkout master && git pull && git checkout -b main
- Push main to origin and set-up tracking:
git push -u origin main
- Set main as default branch and adjust branch protections in Gitlab/Github settings
- Instruct your fellow developers who have local clones of the repo to follow the steps below. Once everyone is done updating:
- Delete master branch in Gitlab/Github
- Make sure code tree is clean, ie. all changes are committed or stashed away. Also ensure that your local master branch is identical to the remote one.
- Update local git repo:
git checkout -t origin/main
git remote set-head origin -a && git remote prune origin
git branch -d master
Running git branch
should now only display main among your local branches.