# How to switch a git repository to use the main branch as trunk
Topics: [[Git version control]]
## Gitlab
Rename the branch locally:
```shell
git branch -m master main
```
Update files still referencing `master` and commit the changes.
Push to Gitlab:
```
git push -u origin main
```
In "Settings", "Repository", update the "Default Branch" setting.
In "Settings", "Repository", add `main` under "Protected Branches", using the same settings as set for `master`. Then set `master` to allow merges and pushes from "No one".
Finally, delete the `master` branch in "Repository", "Branches". The merge and push protection made earlier will still apply.
## Related
-