<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Protected branches > 原文:[https://docs.gitlab.com/ee/user/project/protected_branches.html](https://docs.gitlab.com/ee/user/project/protected_branches.html) * [Overview](#overview) * [Configuring protected branches](#configuring-protected-branches) * [Using the Allowed to merge and Allowed to push settings](#using-the-allowed-to-merge-and-allowed-to-push-settings) * [Restricting push and merge access to certain users](#restricting-push-and-merge-access-to-certain-users-starter) * [Wildcard protected branches](#wildcard-protected-branches) * [Creating a protected branch](#creating-a-protected-branch) * [Deleting a protected branch](#deleting-a-protected-branch) * [Protected Branches approval by Code Owners](#protected-branches-approval-by-code-owners-premium) * [Running pipelines on protected branches](#running-pipelines-on-protected-branches) * [Changelog](#changelog) # Protected branches[](#protected-branches "Permalink") GitLab 中的[權限](../permissions.html)基本上是圍繞對存儲庫和分支具有讀或寫權限的想法定義的. 為了對某些分支機構施加進一步的限制,可以對其進行保護. ## Overview[](#overview "Permalink") 默認情況下,受保護的分支執行以下四個簡單的操作: * 它會阻止除具有維護者權限的用戶之外的所有用戶創建它(如果尚未創建). * 它可以防止除具有**允許的**權限的用戶以外的其他任何人推送. * 它可以防止**任何人**用力推動分支機構. * 它可以防止**任何人**刪除分支. **注意:**允許 GitLab 管理員推送到受保護的分支. 有關隨時間的變化,請參見" [更改日志"](#changelog)部分. 默認的分支保護級別在[管理區域中](../admin_area/settings/visibility_and_access_controls.html#default-branch-protection)設置. ## Configuring protected branches[](#configuring-protected-branches "Permalink") 要保護分支,您需要至少具有維護者權限級別. 請注意,默認情況下`master`分支是受保護的. 1. 導航到項目的**"設置"?"存儲庫"** 2. 滾動查找" **受保護的分支"**部分. 3. 從" **分支"**下拉菜單中,選擇要保護的分支,然后單擊" **保護"** . 在下面的屏幕截圖中,我們選擇了`develop`分支. [![Protected branches page](https://img.kancloud.cn/ae/a9/aea917875484cc53df22a2cbcc7a6553_855x458.png)](img/protected_branches_page_v12_3.png) 4. 完成后,受保護的分支將出現在"受保護的分支"列表中. [![Protected branches list](https://img.kancloud.cn/00/fc/00fc80090cf260b177728df3450734a3_856x196.png)](img/protected_branches_list_v12_3.png) ## Using the Allowed to merge and Allowed to push settings[](#using-the-allowed-to-merge-and-allowed-to-push-settings "Permalink") 在 GitLab 8.11 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/5081) . 從 GitLab 8.11 開始,我們增加了分支保護的另一層,它提供了對受保護分支的更精細的管理. "開發人員可以推送"選項由"允許推送"設置代替,該設置可以設置為允許/禁止維護者和/或開發人員推送到受保護的分支. 使用"允許推送"和"允許合并"設置,您可以控制不同角色可以在受保護分支中執行的操作. 例如,您可以將"允許推送"設置為"無人",將"允許合并"設置為"開發人員+維護人員",以要求*每個人都*提交合并請求,以請求更改進入受保護分支. 這與[GitLab 工作](../../topics/gitlab_flow.html)流程等[工作流程](../../topics/gitlab_flow.html)兼容. 但是,有些工作流程不需要這樣做,只有防止強行推動和移除分支才有用. 對于這些工作流程,您可以通過將"允許推送"設置為"開發人員+維護人員"來允許具有寫訪問權的每個人推送到受保護的分支. 您可以在創建受保護的分支時設置"允許推送"和"允許合并"選項,也可以在之后通過從"已保護"區域的下拉列表中選擇所需的選項來設置. [![Developers can push](https://img.kancloud.cn/67/e1/67e18f7ac1d7ab022a8409bd6246e904_858x244.png)](img/protected_branches_devs_can_push_v12_3.png) 如果在創建受保護的分支時未選擇任何這些選項,則默認情況下會將它們設置為"維護者". ## Restricting push and merge access to certain users[](#restricting-push-and-merge-access-to-certain-users-starter "Permalink") [Introduced](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/5081) in [GitLab Starter](https://about.gitlab.com/pricing/) 8.11. 使用 GitLab 企業版,您可以通過選擇角色(維護者,開發者)以及某些用戶來限制對受保護分支的訪問. 從下拉菜單中選擇您要合并或推送訪問的角色和/或用戶. [![Select roles and users](https://img.kancloud.cn/fa/89/fa89a796de997156fe7d01bb9cc271de_940x330.png)](img/protected_branches_select_roles_and_users.png) 單擊" **保護"** ,該分支將出現在"受保護的分支"列表中. [![Roles and users list](https://img.kancloud.cn/bc/a8/bca8f26050761aec56c5a98b5319af1b_936x166.png)](img/protected_branches_select_roles_and_users_list.png) ## Wildcard protected branches[](#wildcard-protected-branches "Permalink") 在 GitLab 8.10 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/4665) . 您可以指定一個通配符保護的分支,該分支將保護所有與通配符匹配的分支. 例如: | 通配符保護的分支 | 匹配分支 | | --- | --- | | `*-stable` | `production-stable`, `staging-stable` | | `production/*` | `production/app-server`, `production/load-balancer` | | `*gitlab*` | `gitlab`, `gitlab/staging`, `master/gitlab/production` | 受保護的分支設置(如"開發人員可以推送")適用于所有匹配的分支. 兩個不同的通配符可能會匹配同一分支. 例如, `*-stable` `production-stable`和`production-*`都將與`production-stable`分支匹配. 在這種情況下,如果*這些*受保護的分支有這樣一個設定"允許推送",然后`production-stable`也將繼承這一設置. 如果單擊受保護分支的名稱,將顯示所有匹配分支的列表: [![Protected branch matches](https://img.kancloud.cn/02/c2/02c286fb70232131d109afc48d417d27_930x224.png)](img/protected_branches_matches.png) ## Creating a protected branch[](#creating-a-protected-branch "Permalink") 在 GitLab 11.9 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/53361) . 當受保護的分支或通配符受保護的分支設置為" [**不允許任何人** **推送"時**](#using-the-allowed-to-merge-and-allowed-to-push-settings) ,只要允許開發人員(和具有較高[權限級別的](../permissions.html)用戶) [**合并**](#using-the-allowed-to-merge-and-allowed-to-push-settings) ,就可以創建新的受保護分支. 這只能通過 UI 或 API 來完成(為避免意外地從命令行或 Git 客戶端應用程序創建受保護的分支). 通過用戶界面創建新分支: 1. Visit **資料庫>分支機構**. 2. Click on **新分支**. 3. 填寫分支名稱,然后選擇一個現有的分支,標記或確認新分支將基于該分支. 僅接受現有的受保護分支和已經在受保護分支中的提交. ## Deleting a protected branch[](#deleting-a-protected-branch "Permalink") 在 GitLab 9.3 中[引入](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/21393) . 有時可能需要刪除或清理受保護的分支. 具有[維護者權限](../permissions.html)并具有[維護者權限的](../permissions.html)用戶可以通過 GitLab 的 Web 界面手動刪除受保護的分支: 1. Visit **資料庫>分支機構** 2. 單擊您要刪除的分支旁邊的刪除圖標 3. 為了防止意外刪除,需要額外的確認 [![Delete protected branches](https://img.kancloud.cn/b4/00/b4003680efa9bd7e968db90bedab3a3a_877x344.png)](img/protected_branches_delete.png) 只能通過 Web 界面而不是 Git 刪除受保護的分支. 這意味著您不能從命令行或 Git 客戶端應用程序中意外刪除受保護的分支. ## Protected Branches approval by Code Owners[](#protected-branches-approval-by-code-owners-premium "Permalink") [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/13251) in [GitLab Premium](https://about.gitlab.com/pricing/) 12.4. 對于合并請求更改的文件,可能需要[代碼所有者的](code_owners.html)至少一項批準. 可以在保護新分支時設置"代碼所有者"批準,也可以將其設置為已經受保護的分支,如下所述. 要保護新分支并獲得代碼所有者的批準: 1. 導航到項目的**"設置">"存儲庫",**然后展開" **受保護的分支"** . 2. 向下滾動到**保護一個分支** ,選擇**分支**或通配符你想保護,選擇誰的**允許合并** **,**并**允許推** ,以及切換**需要從代碼的業主**滑塊**批準** . 3. Click **Protect**. [![Code Owners approval - new protected branch](https://img.kancloud.cn/05/54/05544b54c7e8a6ecb910c1bbb26aaa46_1972x1042.png)](img/code_owners_approval_new_protected_branch_v12_4.png) 要使代碼所有者批準已受保護的分支機構,請執行以下操作: 1. 導航到項目的**"設置">"存儲庫",**然后展開" **受保護的分支"** . 2. 向下滾動到" **受保護"分支,**然后切換所選分支的**"代碼所有者"批準**滑塊. [![Code Owners approval - branch already protected](https://img.kancloud.cn/05/b7/05b7961822986b15b92178640915e852_1894x308.png)](img/code_owners_approval_protected_branch_v12_4.png) 啟用后,所有針對這些分支的合并請求都將需要代碼所有者根據匹配的規則進行批準,然后才能合并. 此外,如果匹配規則,則拒絕直接推送到受保護的分支. ## Running pipelines on protected branches[](#running-pipelines-on-protected-branches "Permalink") 合并或推送到受保護分支的權限用于定義用戶是否可以運行 CI / CD 管道并在與那些分支相關的作業上執行操作. 有關管道安全模型的詳細信息,請參閱[受保護分支上](../../ci/pipelines/index.html#pipeline-security-on-protected-branches)的安全性. ## Changelog[](#changelog "Permalink") **11.9** * [允許](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/53361)開發人員(和具有更高權限級別的用戶)通過 API 和用戶界面[創建受保護的分支](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/53361) . **9.2** * 允許通過 Web 界面刪除受保護的分支( [問題#21393](https://gitlab.com/gitlab-org/gitlab-foss/-/issues/21393) ). **8.11** * 允許創建無法推送到的受保護分支( [合并請求!5081](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/5081) ). **8.10** * 允許沒有推送訪問權限的開發人員合并到受保護的分支中( [合并請求!4892](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/4892) ). * 允許使用通配符指定受保護的分支( [合并請求!4665](https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/4665) ).
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看