1. 程式人生 > 其它 >[github/gitlab] 遠端倉庫master分支無法清除問題

[github/gitlab] 遠端倉庫master分支無法清除問題

技術標籤:gitTranswarpgitgitlabgithub

[github/gitlab] 遠端倉庫master分支無法清除問題

1. 問題情況

   在近日的專案開發過程中,由於之前在master分支上提交了無用的commit到遠端分支,於是想清空遠端的master分支,提交合並多個commit後的唯一commit。但是在刪除遠端master分支時候遇到了無法清除的情況,如下圖所示:

在這裡插入圖片描述

remote: GitLab: You can only delete protected branches using the web interface.
To http:/172。*****:****/Mars/auto-benchmark-TST.git
 !
[remote rejected] master (pre-receive hook declined) error: 無法推送一些引用到 'http://172.**.**.***:***/Mars/auto-benchmark-TST.git'

2. 解決方法

   檢視報錯資訊,無法刪除保護受保護的分支,只能在網頁介面進行刪除, 解決方法如下

  1. 開啟gitlab,找到自己對應的專案
  2. 點選左側settings的respository
  3. 右側的Default Branch的分支選擇其他分支(結束之後可以更改為master)
  4. 右側Protected Branches 取消master的保護狀態
  5. 本地刪除遠端master分支即可