git 防止 gitlab 保护默认分支的属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26932503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 10:33:48  来源:igfitidea点击:

Property to prevent gitlab from protecting default branches

gitgit-branchgitlab

提问by mniehoff

With version 7.4 gitlab changed the behaviour of protected branches in new projects.

gitlab 7.4 版本改变了新项目中受保护分支的行为。

In every new project the default branch e.g. master is a protected branch, meaning developers are not able to push to it. In my company a lot of developers work on the default/master branch and are now struggeling when starting a new project.

在每个新项目中,默认分支(例如 master)是受保护的分支,这意味着开发人员无法推送到它。在我的公司,很多开发人员在 default/master 分支上工作,现在在开始一个新项目时都很挣扎。

My Question: Is there a property in the ui or in the gitlab.rbto restore the pre 7.4 behaviour and to not protect the default branch?

我的问题:ui 或 in 中是否有属性gitlab.rb来恢复 7.4 之前的行为并且不保护默认分支?

采纳答案by mniehoff

Seems there isn't a default property. But there already is a feature request at feedback.gitlab.com

似乎没有默认属性。但是feedback.gitlab.com上已经有一个功能请求

回答by rderoldan1

I'm not Sure if the is a default param, but per project you can change master as unprotected , in your project, go to settings -> protected branches and unprotect master enter image description here

我不确定这是否是默认参数,但是每个项目您都可以将 master 更改为 unprotected ,在您的项目中,转到设置 - > 受保护的分支并取消保护 master 在此处输入图片说明

Update

更新

The gilt team published a post related to your question!! https://about.gitlab.com/2014/11/26/keeping-your-code-protected/

gilt 团队发布了一篇与您的问题相关的帖子!! https://about.gitlab.com/2014/11/26/keeping-your-code-protected/

回答by Trashman

I'm not sure what version the feature was added, but in version 8.9.4 you can now select to allow Developers to Push to a protected project.

我不确定添加了哪个版本的功能,但在 8.9.4 版本中,您现在可以选择允许开发人员推送到受保护的项目。

Also, you now have to click the gear widget dropdown in the upper right to get to the "Protected Branches" options in your project. (See below)Git Screen Shot

此外,您现在必须单击右上角的齿轮小部件下拉菜单才能进入项目中的“受保护分支”选项。(见下文)Git 屏幕截图

回答by pixelbrackets

Is there a property in the ui or in the gitlab.rb to restore the pre 7.4 behaviour and to not protect the default branch?

ui 或 gitlab.rb 中是否有属性可以恢复 7.4 之前的行为并且不保护默认分支?

This is possible in version 12.5:

这在 12.5 版中是可能的:

Global Setting(for all new projects):

全局设置(适用于所有新项目):

  • Admin Area > Settings > General > Tab ?Visibility and access controls? > Field ?Default branch protection?
  • Select Not protected: Both developers and maintainers can push new commits, force push, or delete the branch.
  • 管理区域 > 设置 > 常规 > 选项卡?可见性和访问控制?> 领域?默认分支保护?
  • 选择 Not protected: Both developers and maintainers can push new commits, force push, or delete the branch.

Admin area screnshot

管理区域截图

Project Setting(for an existing project):

项目设置(对于现有项目):

  • Project > Settings > Repository > Tab ?Protected Branches? > Field ?Protected branch?
  • Click Unprotectbutton next to masterbranch
  • 项目 > 设置 > 存储库 > 选项卡?受保护的分支?> 领域?受保护的分支?
  • 单击分支Unprotect旁边的按钮master

Project settings screenshot

项目设置截图

Please note: The branch protection was introduced for a very good reason:

请注意:引入分支保护是有充分理由的:

Git is very easy to use and abuse. A single git push --force command can easily ruin the day for a lot of people.

https://about.gitlab.com/blog/2014/11/26/keeping-your-code-protected/

Git 非常易于使用和滥用。一个 git push --force 命令很容易毁掉很多人的一天。

https://about.gitlab.com/blog/2014/11/26/keeping-your-code-protected/

回答by Flummox - don't be evil SE

Seems GitLab moves this around a bit, when I wanted to change the access to branches in GitLab Community Edition 9.0.2, here I could find them:

似乎 GitLab 移动了一点,当我想更改对 GitLab Community Edition 9.0.2 中分支的访问权限时,我可以在这里找到它们:

mainpage project > Settings (upper right) > Repository (2nd, slighty darker navbar) > Protected Branches (Scroll down a bit)

主页项目> 设置(右上)> 存储库(第二个,略暗的导航栏)> 受保护的分支(向下滚动一点)

More more info, see docs.GitLab

更多信息,请参阅docs.GitLab