Protect all branches of gitlab

Hi. Can anyone please suggest how to protect all branches by default? If a new branch is created by project maintainer or owner, it should be created as a protected branch, as it is done for the main branch. Thank you.

Hi,

within the project settings, you can specify wildcards for branch names. If you’d just use *, any branch is protected.

https://docs.gitlab.com/ee/user/project/protected_branches.html#wildcard-protected-branches

This must be done for each project though, there’s a feature request to manage this on the group/instance level: https://gitlab.com/gitlab-org/gitlab/issues/18488

If you prefer an automated fashion, use the REST API and iterate over all projects and set the protected branches this way: https://docs.gitlab.com/ee/api/protected_branches.html

Cheers,
Michael

Thank you very much. I will look into this.

With Best Regards,
Fazil