简体   繁体   中英

GitLab - Determine if branch is protected from terminal git command

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.

https://docs.gitlab.com/ee/api/protected_branches.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM