2010-02-04 59 views
11

我想從中央git存儲庫中刪除遠程分支。通常的建議是'git push origin:branchname'或'git push origin:heads/branchname'。但是當我嘗試的時候,我得到這個錯誤信息:無法刪除git中的遠程分支

*** Deleting a branch is not allowed in this repository
error: hooks/update exited with error code 1
error: hook declined to update refs/heads/branchname
To /opt/repo/myrepo.git
! [remote rejected] branchname (hook declined)
error: failed to push some refs to '/opt/repo/myrepo.git'

什麼給?如果有幫助,我使用git版本1.5.4.3。

回答

19

有人在遠程倉庫中啓用了禁止刪除的鉤子 - 通常這樣做是爲了讓別人無法將重新設置的分支推送到倉庫中。 (我保留了一個相當大的git存儲庫集合,並且它們都是以這種方式配置的,雖然沒有掛鉤。)

查看遠程存儲庫中的掛接/目錄。將會有一個名爲「update」的腳本;這是什麼拒絕讓你刪除分支。

+7

謝謝!有了這些信息,我可以解決這個問題:'git --git-dir /opt/repo/myrepo.git config --bool hooks.allowdeletebranch true'。做完這些之後,我可以使用'git push origin:branchname'來刪除遠程分支。 – twirlip 2010-02-05 03:27:04

+1

@twirlip:太棒了,很高興你能夠修復它。 – ebneter 2010-02-05 06:08:46

+1

我低估了答案,因爲它提供了一個提示,但沒有另外解釋就沒有解決問題。相反,第一個評論沒有神奇:) – yoshi 2012-08-02 08:27:23

2

您可能必須登錄到遠程存儲庫並手動刪除分支(即 - 從文件系統)。

3

我想這可能是消息所說的:遠程存儲庫不允許任何刪除歷史記錄。如果你真的需要這個功能,考慮不同的git託管(如果你不能調整你當前使用的設置)。

+1

存儲庫託管在本地(好吧,它在服務器上,我有root訪問權限,無論如何)。如果可以對repo進行配置更改以啓用此功能,我很想知道它。 – twirlip 2010-02-04 02:43:04