GitLab - Determine if branch is protected from terminal git command

Viewed 3084

Is there a method to determine if a branch is protected in GitLab using the git command?

Preferably an approach to determine protected status without trying to do something illegal and receiving a warning.

2 Answers

There is no way you can do that using git command-line.

But, there an alternative. You can install - a pypi module:

pip install python-gitlab

Here is the documentation, you can refer.

To get the information about the protected branches, you can do:

p_branches = project.protectedbranches.list()

using python.

Here is another question I found, which is similar to yours.

Edit:

Here is the gitlab api. The endpoint to get the protected branches is give as:

/projects/:id/protected_branches
Related