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.
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.
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
Protected branch isn't a git feature.
It's a feature of tools like gitlab or github.
Maybe you can get the protected branch of a repository through gitlab api and make verification before you push.