Prevent push to master/main branch by anybody

Is there a way to prevent everyone from pushing code directly to the master/main branch for every project? I found a way to do it for each project, but we have many. I have accidently pushed code myself into the main branch when I forgot to create a new branch. I am the repository owner, and I do not want to be able to do this.

Thanks.

1 Like

Hi @JavaUser
there is an option if you are using self-hosted Default branch | GitLab

I am not sure if it’s possible on Gitlab.com

We are using GitLab.com. I have not been able to find an option to do this.