How to know who protected a branch?

Hi,

While the user push code to a master branch, the message shows the user doesn’t have permission to push the code to the protected master branch.

Is there a way to know who protected the master branch?

And is there a way to protect a branch by API?

Thanks

Hi,

the default branch (master, main, or let’s just say the HEAD reference) is protected by default in GitLab by GitLab itsself on creation of the repository or the first push to an empty repository. See Protected Branches

The API is described here: API Ressources > Protected branches API > Protect repository branches

If you host your own gitlab instance you could find out who personally protected a branch if you look into the logs who did a POST to /<full-project-path>/-/protected_branches. E.g. /mygroup/mysubgroup/myproject/-/protected_branches.

I have not seen this information avaliable in the WEB-UI yet.

kind regards
Markus

Hi mkoehl,

Do you know where the log is?

Thanks,
Jason

The documentation describes all log files and the location where you can find them: GitLab Doc > Log system

My wild guess would be NGINX Logs and production_json.log | production.log