tags:

views:

324

answers:

3

I'd like to delete a remote branch from my central git repository. The usual advice is to do 'git push origin :branchname' or 'git push origin :heads/branchname'. But when I try that, I get this error message:

*** 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'

What gives? I'm using git version 1.5.4.3, if that helps.

A: 

You might have to log into your remote repository and delete the branch manually (ie - from the file system).

Chris J
+1  A: 

I think this might be what the message says: the remote repository does not permit any removal of history. Consider different git hosting (if you cannot adjust the settings on what you are currently using) if you really need this functionality.

Tronic
The repository is hosted locally (well, it's on a server that I have root access on, anyway). If there's a configuration change that can be made to the repo to enable this functionality, I'd love to know about it.
twirlip
+4  A: 

Someone has enabled a hook in the remote repo that is prohibiting the delete -- this is usually done so that someone can't push a rebased branch into the repo. (I maintain a fairly large collection of git repositories and they are all configured this way, although not with a hook.)

Look in the hooks/ directory in the remote repository. There will be a script named "update"; this is what's refusing to let you delete the branch.

ebneter
Thanks! With this info I was able to work out this solution: 'git --git-dir /opt/repo/myrepo.git config --bool hooks.allowdeletebranch true'. After doing that, I was able to use 'git push origin :branchname' to delete the remote branch.
twirlip
@twirlip: fantastic, glad you were able to get it fixed.
ebneter