问题
Am aware of how its done from the GitLab UI (http://gitlabdomain.com/ProjectNamespace/Project/protected_branches), but is there a way to "Protect" a particular branch from the command line?
回答1:
Sure, you need a third-party command-line tool for that though, or use the REST API directly yourself.
Check http://www.rubydoc.info/gems/gitlab/frames which is listed on https://about.gitlab.com/applications/
回答2:
You cant protect branch from the command line.
Git doesn't know how did you execute the command.
All the gui tools are executing git commands which are CLI behind the scenes.
So your answer is NO
What you can do might be able to pass special parameter along with the git lag commands -c
flag to any command and then check it in your server hooks to verify that the command came from GUI and not from CLI.
来源:https://stackoverflow.com/questions/34509475/gitlab-is-there-a-way-to-protect-a-branch-from-command-line