Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab: Is there a way to protect a branch from command line?

Tags:

git

gitlab

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?

like image 633
Pranesh Vittal Avatar asked Oct 31 '22 12:10

Pranesh Vittal


2 Answers

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/

like image 76
marcolz Avatar answered Nov 15 '22 06:11

marcolz


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.

like image 43
CodeWizard Avatar answered Nov 15 '22 07:11

CodeWizard